如何从 tf.estimator.Estimator 中选择一个层并访问该层中每个单元的权重向量?具体来说,我正在尝试可视化密集层的权重。
查看https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/python/layers/core.py似乎权重被称为内核,但在使用估计器抽象时我无法访问它们。
Ps:关于Estimator的实现示例,我们引用https://www.tensorflow.org/get_started/estimator
最佳答案
估算器 has a method称为get_variable_value
。因此,一旦您生成了检查点(或从其中加载了变量值),并且如果您知道密集层的名称,则可以使用 matplotlib 执行类似的操作:
import matplotlib.pyplot as plt
weights = estimator.get_variable_value('dense/kernel')
plt.imshow(weights, cmap='gray')
plt.show()
关于debugging - 如何可视化 TensorFlow Estimator 权重?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45863744/