Obtaining output of an Intermediate layer in TensorFlow/Keras

The easiest way is to create a new model in Keras, without calling the backend. You’ll need the functional model API for this:

from keras.models import Model

XX = model.input 
YY = model.layers[0].output
new_model = Model(XX, YY)

Xaug = X_train[:9]
Xresult = new_model.predict(Xaug)

Leave a Comment