0

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.

1 Answer 1

1

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])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.