Search code examples
tensorflowkerasdeep-learningcomputer-visionmobilenet

image size issue to train cifar dateset by standard mobileNet,VGG-16 or AlexNet from scratch in tensorflow or keras


Suppose,I want to train standard AlexNet, VGG-16 or MobileNet from scratch by CIFAR-10 or CIFAR-100 dataset in Tensorflow or Keras.Now the problem is that,the architecture of standard AlexNet,VGG-16 or MobileNet is built for ImageNet dataset where each image is 224*224 but in CIFAR-10 or CIFAR-100 dataset,each image is 32*32.So which of the following I should do???

  1. Resize each image in CIFAR-10 or CIFAR-100 dataset from 32*32 to 224*224 and than train standard AlexNet,MobileNet or VGG-16 on that modified image dataset.

or

  1. Change the Architecture of standard MobileNet,AlexNet or VGG-16(number of layers or stride or filter size) so that the modified Architecture can feed the 32*32 image of CIFAR-10 or CIFAR-100 dataset.

if answer is option 1,please suggest some how I resize a batch of image in tensorflow or keras

or if answer is option 2,please suggest some architecture for MobileNet,VGG-16 or Alexnet(layers,stride,filters) to train them in Cifar dataset of 32*32 image

Thanks in advance.


Solution

  • Actually you can specify the input shape of thoses network, if you read the documentation you can see that (32, 32, 3) is a correct input value :

    https://keras.io/applications/#mobilenet
    https://keras.io/applications/#vgg16

    input_shape: optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (224, 224, 3) (with 'channels_last' data format) or (3, 224, 224) (with 'channels_first' data format). It should have exactly 3 inputs channels, and width and height should be no smaller than 32. E.g. (200, 200, 3) would be one valid value.

    You can also reshape all of your images, but i don't think this is a good idea, 224*224 images on thoses networks will be very long to train.