Skip to content
Advertisement

Reshaping MNIST for ResNet50

I am trying to train the mnist dataset on ResNet50 using the Keras library. The shape of mnist is (28, 28, 1) however resnet50 required the shape to be (32, 32, 3)

How can I convert the mnist dataset to the required shape?

JavaScript
JavaScript
JavaScript
JavaScript

Advertisement

Answer

You need to resize the MNIST data set. Note that minimum size actually depends on the ImageNet model. For example: Xception requires at least 72, where ResNet is asking for 32. Apart from that, the MNIST is a grayscale image, but it may conflict if you’re using the pretrained weight of these models. So, good and safe side is to resize and convert grayscale to RGB.


Full working code for you.

Data Set

We will resize MNIST from 28 to 32. Also, make 3 channels instead of keeping 1.

JavaScript
JavaScript

ResNet 50

JavaScript

Train

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement