Reputation: 1
I am trying to do a project where the values of hidden layers play a pivotal role. I am trying to use a sample autoencoder from this tutorial, https://blog.keras.io/building-autoencoders-in-keras.html I am able to do the gradient descent and it is also converging, but I am not sure how to print the values of the hidden layer. When I use print state on the model.outputs, I get tf.Tensor 'add:0' shape=(?, 30) dtype=float32, where 30 is number of nodes in the hidden layer. Can anyone help? Thanks.
Upvotes: 0
Views: 1089
Reputation: 7148
This has to be done using Keras functions as you can read here: (https://keras.io/getting-started/faq/#how-can-i-obtain-the-output-of-an-intermediate-layer).
In essence you build a function like this:
import keras.backend as K
output_func = K.function([model.layers[0].input, K.learning_phase()],
[model.layers[1].output])
intermediate_output = output_func([data, False])
Upvotes: 1