How to replace (or insert) intermediate layer in Keras model?

后端 未结 4 450
温柔的废话
温柔的废话 2021-01-30 14:12

I have a trained Keras model and I would like:

1) to replace Con2D layer with the same but without bias.

2) to add BatchNormalization layer before first Activati

4条回答
  •  日久生厌
    2021-01-30 14:32

    Unfortunately replacing a layer is no small feat for models that do not follow the sequential pattern. For sequential patterns it is OK to just x = layer(x) and replace with new_layer when you see fit as in the previous answer. However, for models that do not have a classic sequential pattern (say you have a simple "concatenation" of two columns) you have to actually "parse" the graph and use your "new_layer" (or layers) in the right places. Hope this is not too discouraging and happy graph parsing and reconstructing :)

提交回复
热议问题