Keras Autoencoders - 如何可视化隐藏层的值?

时间:2017-03-15 22:49:32

标签: tensorflow deep-learning keras autoencoder keras-layer

我正在尝试一个隐藏图层的值发挥关键作用的项目。我正在尝试使用本教程中的示例自动编码器, https://blog.keras.io/building-autoencoders-in-keras.html 我能够进行渐变下降并且它也会收敛,但我不确定如何打印隐藏层的值。当我在model.outputs上使用print state时,我得到tf.Tensor'add:0'shape =(?,30)dtype = float32,其中30是隐藏层中的节点数。有人可以帮忙吗?感谢。

1 个答案:

答案 0 :(得分:1)

这必须使用Keras函数完成,您可以在这里阅读:(https://keras.io/getting-started/faq/#how-can-i-obtain-the-output-of-an-intermediate-layer)。

从本质上讲,你构建了一个这样的函数:

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])
相关问题