python - Keras 在 model.fit() 之后删除图层

标签 python theano keras keras-layer

我正在使用 Keras 进行建模工作,我想知道是否可以通过索引或名称删除某些层?目前我只知道 model.pop() 可以完成这项工作,但它只是删除了最近添加的图层。此外,layerstensorvariable 的类型,我不知道如何删除可以在 numpy array 中完成的某些元素>列表。顺便说一句,我正在使用 Theano 后端。

最佳答案

model.pop() 只是删除最后添加的层是正确的,没有其他记录的删除中间层的方法。

您始终可以像这样获得任何中间层的输出:

 base_model = VGG19(weights='imagenet')
 model = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_pool').output)

示例取自此处:https://keras.io/applications/

然后在其上添加新图层。

关于python - Keras 在 model.fit() 之后删除图层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40652929/

相关文章:

theano - 为什么 theano 运行这么慢?

python - 训练模型来预测简单的线性函数

python - 为什么 pip 中有用的命令行选项未记录并明确隐藏?

python - 在Integrate.quad中使用上限作为数组

Python 美汤 : Target a particular element

python - Theano值错误: Some matrix has no unit stride

python - 'str' 对象不支持项目分配 - django 错误

python - 当 channel 数增加时,ResNet 快捷连接的零填充

tensorflow - 在 Tensorflow 2 中将梯度可视化为热图

Keras:解释 get_weights() 的输出