My Detailed Notes: minitorch | 十派的玩具箱
A compact deep learning systems project based on the MiniTorch teaching framework. This repository focuses on implementing core autodiff and tensor operators, then using them to train CNN models for sentiment classification and image classification.
- Implemented MiniTorch core components such as autodiff, tensor operations, module/parameter management, and fast operators.
- Implemented neural network operators including
Conv1D,Conv2D, pooling, dropout, andlogsoftmax. - Ran end-to-end training on:
- SST-2 sentiment classification
- MNIST digit classification
- Added modern training scripts for easier reproduction with PyTorch and Hugging Face.
minitorch/
|- minitorch/ # framework core
|- project/ # original MiniTorch training scripts
| |- run_sentiment.py
| |- run_mnist_multiclass.py
| |- app.py
| |- data/
|- scripts/ # modern training scripts
| |- train_sentiment_hf.py
| |- train_mnist_torch.py
|- tests/
|- requirements.txt
|- requirements-modern.txt
conda create -n myminitorch python=3.11
conda activate myminitorch
pip install -r requirements.txt
pip install -e .If you want to use the modern training scripts:
pip install -r requirements-modern.txtPut the following files under project/data/:
train-images-idx3-ubytetrain-labels-idx1-ubyte
Example:
mkdir -p project/data
cd project/data
wget -c https://storage.googleapis.com/cvdf-datasets/mnist/train-images-idx3-ubyte.gz
wget -c https://storage.googleapis.com/cvdf-datasets/mnist/train-labels-idx1-ubyte.gz
gunzip -kf train-images-idx3-ubyte.gz
gunzip -kf train-labels-idx1-ubyte.gz
cd ../..For the original MiniTorch sentiment script, it is recommended to set:
export HF_HOME=/root/shared-nvme/minitorch/project/data/hf_cache
export EMBEDDINGS_ROOT=/root/shared-nvme/minitorch/project/dataThis stores:
- SST-2 cache under
project/data/hf_cache/ - GloVe files under
project/data/glove/
The modern Hugging Face sentiment script only needs HF_HOME; it does not use GloVe.
python project/run_sentiment.py | tee sentiment.txt
python project/run_mnist_multiclass.py | tee mnist.txtpython scripts/train_sentiment_hf.py \
--output-dir outputs/sst2-hf \
--max-train-samples 2000 \
--max-eval-samples 500
python scripts/train_mnist_torch.py \
--data-dir project/data \
--output-dir outputs/mnist-torch \
--epochs 5streamlit run project/app.pyBuilt and extended a MiniTorch-based deep learning systems project, implementing autodiff, tensor operators, and CNN modules, then validating the framework on SST-2 sentiment classification and MNIST image classification.

