【发布时间】:2019-08-14 11:34:33
【问题描述】:
我正在尝试微调 VGG16 模型。我已经删除了最后 5 层
(*block5_pool (MaxPooling2D),flatten(Flatten),fc1 (Dense),fc2 (Dense),predictions (Dense)*).
现在,我想添加一个全局平均池化层,但出现此错误
输入 0 与层 global_average_pooling2d_4 不兼容:预期 ndim=4,发现 ndim=2**
这里似乎有什么问题?
model = VGG16(weights='imagenet', include_top=True)
model.layers.pop()
model.layers.pop()
model.layers.pop()
model.layers.pop()
model.layers.pop()
x = model.output
x = GlobalAveragePooling2D()(x)
【问题讨论】:
-
全局平均池化层是的,它必须和其他层一样是 4d,并且您有一些 2d 输入
标签: python tensorflow keras deep-learning vgg-net