This notebook demonstrate the use of PyTorch to create a Multi-Layer Perceptron for Image Classification on Fashion Mnist Dataset.
I have used Fashion Mnist Dataset which contains:
- 60K training datapoint.
- 10K test datapoints.
- 10 Categories.
Label | Description |
---|---|
0 | T-shirt/top |
1 | Trouser |
2 | Pullover |
3 | Dress |
4 | Coat |
5 | Sandal |
6 | Shirt |
7 | Sneaker |
8 | Bag |
9 | Ankle boot |
The model used is a Pytorch Sequential model with the following architecture.
Sequential( (0): Linear(in_features=784, out_features=128, bias=True) (1): ReLU() (2): Dropout(p=0.2) (3): Linear(in_features=128, out_features=64, bias=True) (4): ReLU() (5): Dropout(p=0.2) (6): Linear(in_features=64, out_features=10, bias=True) (7): LogSoftmax() )
Classification report on the test data set:
Label | f1-score | precision | recall | support | |
---|---|---|---|---|---|
0 | T-shirt/top | 0.800395 | 0.821501 | 0.780347 | 519.0 |
1 | Trouser | 0.966732 | 0.951830 | 0.982107 | 503.0 |
2 | Pullover | 0.743383 | 0.674322 | 0.828205 | 390.0 |
3 | Dress | 0.830612 | 0.814000 | 0.847917 | 480.0 |
4 | Coat | 0.751342 | 0.876827 | 0.657277 | 639.0 |
5 | Sandal | 0.931206 | 0.906796 | 0.956967 | 488.0 |
6 | Shirt | 0.576375 | 0.546332 | 0.609914 | 464.0 |
7 | Sneaker | 0.921105 | 0.934000 | 0.908560 | 514.0 |
8 | Bag | 0.959402 | 0.947257 | 0.971861 | 462.0 |
9 | Ankle boot | 0.945489 | 0.961759 | 0.929760 | 541.0 |
micro avg | 0.843600 | 0.843600 | 0.843600 | 5000.0 | |
macro avg | 0.842604 | 0.843462 | 0.847292 | 5000.0 | |
weighted avg | 0.844092 | 0.850633 | 0.843600 | 5000.0 |