In this lab we will train a CNN with CIFAR-10 dataset using PyTorch deep learning framework.

Submit your assignment








 


Lab 2: Train a CNN on CIFAR-10 Dataset
ENGN8536, 2018
August 13, 2018
In this lab we will train a CNN with CIFAR-10 dataset using PyTorch deep learning framework.
CIFAR-10 dataset contains 50000 training images and 10000 testing images. Images are 32×32
RGB images.
Complete the following exercises:
1. Load CIFAR-10 dataset from torchvision.
2. Separate the training set to 49000 images used for training and 1000 images used for validation.
(Can use torch.utils.data.SubsetRandomSampler)
3. When loading the data, normalize the data to range between (-1, 1). Also perform the
following data augmentation when training:
• randomly flip the image left and right
• zero-pad 4 pixels on each side of the input image and randomly crop 32×32 as input to
the network.
4. Build a CNN with the following architecture:
• 5×5 Convolutional Layer with 32 filters, stride 1 and padding 2.
• ReLU Activation Layer
• Batch Normalization Layer
• 2×2 Max Pooling Layer with a stride of 2
• 3×3 Convolutional Layer with 64 filters, stride 1 and padding 1.
• ReLU Activation Layer
• Batch Normalization Layer
• 2×2 Max Pooling Layer with a stride of 2
• Fully-conneted layer with 1024 output units
• ReLU Activation Layer
• Fully-connected layer with 10 output units
5. Set up cross-entropy loss.
6. Set up Adam optimizer, with 1e-3 learning rate and betas=(0.9, 0.999).
7. Train your model. Draw the following plots:
• Training loss vs. epochs
• Training accuracy vs. epochs
• Validation loss vs epochs
• Validation accuracy vs. epochs
You can either use Tensorboard to draw the plots or you can save the data (e.g. in a
dictionary) then use Matplotlib to plot the curve.
(8 marks up to here)
1
8. (2 marks) Train a good model. Marks will be awarded for high performances and good
design. You are not allowed to use pre-trained model, you should train the model yourself.
Reseources:
• PyTorch CIFAR-10 tutorial: https://pytorch.org/tutorials/beginner/blitz/cifar10_
tutorial.html
• PyTorch Documentation: https://pytorch.org/docs/stable/index.html
• Deeper models implementation: https://github.com/pytorch/vision/tree/master/torchvision/
models
2

Click here to order this assignment @Essaywriting.us.No Plagiarism.Written from scratch by professional writers.

Leave a Reply

Your email address will not be published. Required fields are marked *