在Keras使用经过预先训练的网络

时间:2016-12-22 09:31:11

标签: python neural-network keras pre-trained-model

我正在尝试在Keras进行转学,但却找不到好的例子。我在尝试这个时遇到错误:

model = Sequential()

input_tensor = Input(shape=(48,48,3))
model.add(VGG16(weights='imagenet', include_top=False, input_tensor=input_tensor))

model.add(Convolution2D(32, 3, 3, border_mode="valid", input_shape=(48,48,3)))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.2))

model.add(Flatten())
model.add(Dense(128, name="hidden1"))
model.add(Activation('relu'))

model.add(Dense(4, name="output"))
model.add(Activation('softmax'))

我收到错误:ValueError: Negative dimension size caused by subtracting 3 from 1 for 'Conv2D_68' (op: 'Conv2D') with input shapes: [?,1,1,512], [3,3,512,32].

错误出现在我添加了VGG16的行上

非常感谢任何帮助

0 个答案:

没有答案