Deep Learning Lab: Translated MLP - CNN

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Deep Learning Lab

Translated MLP - CNN


Outline
- Analyse and validate one fundamental flaw of MLP

- Learn how to use some basic torchvision transformations

- Introduce Convolutional Neural Network (CNN)

- Learn to use PyTorch for training your first CNN

- Some assignments: how to fine-tune pre-trained network (e.g. AlexNet)


Revisiting Multi-Layer Perceptron
MNIST digits (centered)
MNIST digits (translated)
Train a MLP with translated MNIST
- We have seen that a single layer MLP is quite good for MNIST classification
(accuracy ~ 96%)

- Can a MLP achieve the same accuracy when the MNIST digits are no longer
centered but translated?
Train a MLP with translated MNIST
- We have seen that a single layer MLP is quite good for MNIST classification
(accuracy ~ 96%)

- Can a MLP achieve the same accuracy when the MNIST digits are no longer
centered but translated?

- Let’s find it out by ourselves.


Session 1
Translated MNIST
Convolutional Neural Network
- A convolutional neural network (CNN) consists of an input and an output layer,
as well as multiple hidden layers.

- The hidden layers of a CNN typically consist of :


- convolutional layers
- ReLU layer i.e. activation function
- pooling layers (e.g. Max Pooling)
- fully connected layers (we have already seen this)
- normalization layers (we will see this in a later lab session)
Convolutional Layer
- A Kernel (or filter) is
needed for the
convolution operation.
- Kernel size
(input_channels,
output_channels, height,
width) need to be
specified.
- Note that during
convolution we lose
borders of the images.
Pooling
- Pooling (or subsampling)
is done to reduce the
spatial dimensions of the
feature maps by
retaining most of the
information.
- kernel size and stride of
pooling need to be
specified.
- We will use maxpooling
in our exercise.
Convolution

Normalization
Typical ConvNet Motif

Activation
Function

Pooling
LeNet-5
Session 2
Train LeNet
Home Assignment
- Train a LeNet-5 with
Cifar-10.
- 60000 32x32 colour
images in 10 classes.
- There are 50000
training images and
10000 test images.
- PyTorch supports
Cifar-10 dataset, just
like MNIST
Advanced Assignment
- Modify a network
architecture and apply
necessary
transformations on
Cifar-10 to reach at
least 80% test
accuracy.
- Try and see if you can
reach higher accuracy.
Transfer Learning
Fine-tuning ConvNet
Home Assignment
- Fine-tune Alexnet on rest of the domains of Office-Home.
- Fine-tune other pre-trained networks on Office-Home:
- VGG16
- ResNet50
- Inception V3

- Freeze some initial conv layers of the network and fine-tune only the latter layers
of the network. (Hint: set requires_grad=False for frozen layer weights)
- Compare and see which approach works the best.

You might also like