harbor run -t LiteCoder/cpu-mnist-classification-pipelineharbor download LiteCoder/cpu-mnist-classification-pipelineBuild an end-to-end MNIST classification pipeline in Python using PyTorch that runs entirely on CPU and achieves ≥ 97% test accuracy. The pipeline must include data augmentation, a CNN model, hyperparameter tuning, evaluation, and a CLI inference script.
/appData Preparation: Download MNIST via torchvision, apply data augmentation (at minimum: random rotation and random affine), and split into train/validation/test sets.
Model: Build a CNN that includes at least one residual (skip) connection. The model must be defined in /app/model.py.
Hyperparameter Tuning: Use Optuna to search over at least: learning rate, dropout rate, and weight decay. Run at least 3 trials.
Training: Train the best configuration found by Optuna. Log per-epoch metrics.
Evaluation: Evaluate the final model on the MNIST test set.
CLI Inference: Provide a script at /app/infer.py that accepts a path to a single 28×28 grayscale image and prints the predicted digit.
All output files must be written under /app/output/. Create the directory if it does not exist.
| File | Format | Description |
|---|---|---|
/app/output/best_model.pth |
PyTorch state dict | Saved state dict of the best model |
/app/output/epoch_log.csv |
CSV | Per-epoch training log |
/app/output/results.json |
JSON | Final evaluation results |
/app/output/confusion_matrix.csv |
CSV | 10×10 confusion matrix |
/app/output/classification_report.txt |
Text | scikit-learn classification report |
/app/output/epoch_log.csv
Must contain a header row with at least these columns (additional columns are allowed):
epoch,train_loss,val_loss,val_accuracy
epoch: integer starting from 1train_loss, val_loss: floatval_accuracy: float between 0 and 1/app/output/results.json
Must be valid JSON with at least these top-level keys:
{
"test_accuracy": 0.9712,
"num_epochs": 10,
"best_hyperparameters": {
"learning_rate": 0.001,
"dropout": 0.2,
"weight_decay": 0.0001
}
}
test_accuracy: float between 0 and 1, must be ≥ 0.97num_epochs: positive integerbest_hyperparameters: object containing at least learning_rate, dropout, and weight_decay (all numeric)/app/output/confusion_matrix.csv
A 10×10 CSV file (no header, no index) where row i, column j contains the count of samples with true label i predicted as j. Rows and columns correspond to digits 0–9 in order.
/app/output/classification_report.txt
The output of sklearn.metrics.classification_report written as plain text.
/app/infer.py must:
/app/output/best_model.pth.Example usage:
python /app/infer.py /app/test_image.png
Example output:
7
The final model evaluated on the standard MNIST test set must achieve a test accuracy of at least 0.97 (97%). This value must be reflected in /app/output/results.json under the test_accuracy key.