首页 > 解决方案 > Last fc layers in VGG16

问题描述

The VGG16 architecture has input: 224x224x3 images.I want to have 48x48x3 inputs but to do this in keras, we remove the last fc layers which have 4096 neurons each.Why we have to do this? and is it needed to add another size of fc layers for this input?

标签: tensorflowkerasconv-neural-networkvgg-net

解决方案


VGG16 的最终池化层具有输入图像的维度7x7x512224x224从那里 VGG16 使用全连接层(7x7x512)x4096来获得4096维度输出。但是,由于您的输入大小不同,最终池化层的特征输出维度也会不同(2x2x512我认为)。因此,您需要更改全连接层的矩阵维度以使其工作。不过,您还有另外两个选择

  1. 使用跨空间维度的全局平均池化来获取512维度特征,然后使用少数完全连接的层来获取您的类数。
  2. 调整输入图像的大小224x224x3,您无需更改模型架构中的任何内容。

推荐阅读