如何在 tf.layers.dense 中获得权重? [英] How to get weights in tf.layers.dense?

查看:84
本文介绍了如何在 tf.layers.dense 中获得权重?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在张量板直方图中绘制 tf.layers.dense 的权重,但它没有显示在参数中,我该怎么做?

I wanna draw the weights of tf.layers.dense in tensorboard histogram, but it not show in the parameter, how could I do that?

推荐答案

权重添加为名为 kernel 的变量,因此您可以使用

The weights are added as a variable named kernel, so you could use

x = tf.dense(...)
weights = tf.get_default_graph().get_tensor_by_name(
  os.path.split(x.name)[0] + '/kernel:0')

您显然可以将 tf.get_default_graph() 替换为您正在使用的任何其他图形.  

You can obviously replace tf.get_default_graph() by any other graph you are working in.  

这篇关于如何在 tf.layers.dense 中获得权重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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