如何可视化TensorFlow估算器权重? [英] How to visualize TensorFlow Estimator weights?
问题描述
如何从tf.estimator.Estimator
中选择一个层并访问该层中每个单元的权重向量?具体来说,我正在尝试可视化密集层的权重.
How can I select a layer from a tf.estimator.Estimator
and access the weights vector for each unit in that layer? Specifically, I'm trying to visualize a Dense layer's weights.
查看 https://github. com/tensorflow/tensorflow/blob/r1.3/tensorflow/python/layers/core.py 似乎 weights 被称为 kernels ,但是我使用Estimator抽象时将无法访问它们.
Looking at https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/python/layers/core.py it seems that the weights are called kernels, but I'm not able to access those when using the Estimator abstraction.
Ps:对于Estimator的实现示例,让我们参考 https://www.tensorflow.org /get_started/estimator
Ps: for an example of an implementation of Estimator, let's reference https://www.tensorflow.org/get_started/estimator
推荐答案
估计器 matplotlib :
import matplotlib.pyplot as plt
weights = estimator.get_variable_value('dense/kernel')
plt.imshow(weights, cmap='gray')
plt.show()
这篇关于如何可视化TensorFlow估算器权重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!