I'm creating a neural architecture using the functional API as follows:
x2 = layer1(x1, name='layer1') x3 = layer2(x2, name='layer2') m1 = Model(x1, x3) x5 = layer3(x4, name='layer3') x6 = TimeDistributed(m1)(x5) m2 = Model(x5, x4)
I've trained m2 (with m1 getting implicitly trained). I can access the output of the layers of m2 (say layer3) by creating an intermediate model:
layer_name = 'layer3' intermediate_layer_model = Model(input=model.input, output=model.get_layer(layer_name).output) intermediate_output = intermediate_layer_model.predict(input)
Since m1 is a nested model, I'm not able to access the layers of m1 through m2. How do I obtain the output x3 (layer2's output) when you use the trained m2 to predict on a new data point.