我正在尝试使用FER2013对VGGFace预训练模型进行微调,该模型包括Keras中的48x48图像。由于VGGFace输入形状为224x224x3,因此出现一些错误,例如:
ValueError:第20层(名为“ fc6”),重量具有形状(512, 4096),但所保存的重量具有形状(25088,4096)
任何帮助将不胜感激。
vggface_notop = VGGFace(include_top = 'False', input_shape = (48,48,3))
nb_class = 7
hidden_dim = 512
for layer in vggface_notop.layers:
layer.trainable = False
last_layer = vggface_notop.get_layer('pool5').output
x = Flatten(name = 'flatten')(last_layer)
x = Dense(hidden_dim, activation='relu', name='fc6')(x)
x = Dense(hidden_dim, activation='relu', name='fc7')(x)
out = Dense(nb_class, activation='softmax', name='fc8')(x)
custom_vgg_model = Model(vggface_notop.input , out)
custom_vgg_model.summary()