我正在使用带有“ imagenet”权重的VGG-16进行迁移学习。而不是完全连接的层,我想使用卷积层。下面是代码:
IMG_WIDTH = 224
IMG_HEIGHT = 224
N_CHANNELS = 3
model = applications.VGG16(include_top=False, weights="imagenet", input_shape=(IMG_HEIGHT, IMG_WIDTH,
N_CHANNELS))
for i in range(4) :
model.layers.pop()
for layers in model.layers :
layers.trainable = False
x = Conv2D(32, (7,7), padding = "valid", strides = (1,1), activation="relu",
kernel_initializer=he_normal(seed=42), bias_initializer=zeros())(model.layers[-1].output)
x = Conv2D(16, (1,1), padding = "valid", strides = (1,1), activation="relu",
kernel_initializer=he_normal(seed=42), bias_initializer=zeros())(x)
final_model = Model(model.input, x)
模型架构的最后几层:
此错误的可能原因是什么?