0

I want to train MNIST on VGG16.

MNIST image size is 28*28 and I set the input size to 32*32 in keras VGG16. When I train I get good metrics, but I´m not sure what really happens. Is keras filling in with empty space or is the image being expanded linearly, like in a zoom function? Anyone understands how I can get a test accuracy of +95% after 60 epochs?

Here I define target size:

    target_size = (32, 32)

This is where I define my flow_from_dataframe generator:

train_df = pd.read_csv("cv1_train.csv", quoting=3)

train_df_generator = train_image_datagen.flow_from_dataframe(
    dataframe=train_df,
    directory="../../../MNIST",
    target_size=target_size,
    class_mode='categorical',
    batch_size=batch_size,
    shuffle=False,
    color_mode="rgb",
    classes=["zero","one","two","three","four","five","six","seven","eight","nine"]
) 

Here I define my input size:

model_base = VGG16(weights=None, include_top=False, 
             input_shape=(32, 32, 3), classes=10)
today
  • 32,602
  • 8
  • 95
  • 115
iKnowItAll
  • 33
  • 6
  • Please add code, its not clear what you are doing, because if you set input shape to 32x2, you would get an error. – Dr. Snoopy Apr 20 '19 at 13:27

1 Answers1

0

The images would be simply resized to the specified target_size. This has been clearly stated in the documentation:

target_size: tuple of integers (height, width), default: (256, 256). The dimensions to which all images found will be resized.

You can also inspect the source code and find the relevant part in the load_img function. Also the default interpolation method used to resize the images is nearest. You can find more information about various interpolation methods here (MATLAB) or here (PIL).

today
  • 32,602
  • 8
  • 95
  • 115
  • Im writing a thesis and want to know more about "nearset", since it seem to be the interpolation method. Do you know where I would find more information about it? Ive searched some but dont seem to find anything... – iKnowItAll Apr 21 '19 at 07:52
  • @iKnowItAll Well, you can search with a query like "nearest interpolation image processing". For example, I could find [this](https://www.imageeprocessing.com/2017/11/nearest-neighbor-interpolation.html) or [this](https://www.giassa.net/?page_id=207). Although the MATLAB doc I linked to in my answer also provides a brief explanation. Further, probably you can find relevant information in a reference image processing book. – today Apr 21 '19 at 17:58
  • Thank you so much. YOu wrote "nearset" not "nearest", why I did not find anything. Ill check the litterature! – iKnowItAll Apr 22 '19 at 07:47
  • @iKnowItAll Oh, sorry! Fixed the typo. Thanks for mentioning it. – today Apr 22 '19 at 08:03