【发布时间】:2020-03-18 18:22:46
【问题描述】:
我尝试构建一个以 VGG16 为基础的深度学习模型。我已经使用以下代码在 Keras 中实现了它:
image_input = Input(shape=(224, 224, 3))
model = VGG16(input_tensor=image_input, include_top=True,weights='imagenet')
model.summary()
fc7 = model.get_layer('fc2').output
conv1d = Conv1D(1,5,activation='relu', name="conv1d",input_shape=(1,4096)) (fc7) #error appears here
# flat = Flatten()(conv1d)
fc8 = Dense(512, activation='relu', name="fc8")(conv1d)
#x= Flatten(name='flatten')(last_layer)
out = Dense(num_classes, activation='softmax', name='output')(fc8)
custom_vgg_model = Model(image_input, out)
custom_vgg_model.summary()
我收到以下错误:
ValueError: Input 0 is incompatible with layer conv1d: expected ndim=3, found ndim=2
为什么我们不能像下图那样做连续特征向量的一维卷积? enter link description here
【问题讨论】:
标签: tensorflow keras deep-learning vgg-net