【发布时间】:2019-09-13 06:13:38
【问题描述】:
我有一个预训练的 VGG16 网络,我使用迁移学习修改了 PASCAL VOC 2012 数据集的网络。现在,我想从修改后的 VGG16 网络中获取每一层的输出,并在每一层上应用卷积,然后将它们上采样到相同的大小并添加它们。这是为了识别图像中的重要区域。我已经从每一层获取了输出
output = [layer.output for layer in model.layers]
现在我想要类似的东西
hypercolumns = []
for op in output:
#apply convolution on this output layer
#upsample it to the size of the input image
#store this in hypercolumns list
最后,在对所有层进行上采样后,我将从列表中添加它们以获得单个矩阵。现在,我对如何在不创建模型和进行上采样的情况下应用卷积感到困惑。 keras有没有办法。
【问题讨论】:
-
Now, I am confused on how to apply convolution without creating a model and do upsampling.。为此目的创建模型有什么问题? -
@hushv89 我希望每一层都这样,所以在这种情况下,我会创建太多模型(输出列表中的一层一个模型),而且我必须在一个模型中编译和训练该模型我认为循环不是一个好方法。
-
您可能想查看 Keras 中的
Lambda层。您可以使用 Keras 后端功能来实现您想要做的事情。我不需要您使用Lambda层创建多个模型。只有一个模型。
标签: python tensorflow keras deep-learning conv-neural-network