如果我将输入大小设置为 32,32 mnist 会发生什么

what happens if i set input size to 32,32 mnist

我想在 VGG16 上训练 MNIST。

MNIST 图像大小为 28*28,我在 keras VGG16 中将输入大小设置为 32*32。当我训练时,我得到了很好的指标,但我不确定到底发生了什么。 keras 是用空的 space 填充还是图像正在线性扩展,就像在缩放功能中一样?任何人都知道我如何在 60 个时期后获得 +95% 的测试准确率?

这里我定义目标尺寸:

    target_size = (32, 32)

这是我定义 flow_from_dataframe 生成器的地方:

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"]
) 

这里我定义了我的输入尺寸:

model_base = VGG16(weights=None, include_top=False, 
             input_shape=(32, 32, 3), classes=10)

图像将简单地调整为指定的 target_size。这已在 documentation:

中明确说明

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

您也可以查看源代码并在 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) 中找到相关部分。