Up to Keras version 2.1.6 one was able to "convert" a sequential model to a functional model by accessing the underlying model.model.
Since version 2.2.0 this is no longer possible.
Can it still be done in some other way?
(In case you wonder why I would like to do something like this, I'm maintaining a library that relies on this conversion. :wink:)
Solution:
from keras import layers, models
input_layer = layers.Input(batch_shape=seqmodel.layers[0].input_shape)
prev_layer = input_layer
for layer in seqmodel.layers:
layer._inbound_nodes = []
prev_layer = layer(prev_layer)
funcmodel = models.Model([input_layer], [prev_layer])
Most helpful comment
Solution:
source: https://stackoverflow.com/a/50937113/1866775