如何可视化TensorFlow估算器权重? [英] How to visualize TensorFlow Estimator weights?

查看:374
本文介绍了如何可视化TensorFlow估算器权重?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆