2017-02-17 16 views
7

我無法找到如何添加摘要以可視化已用tf.contrib.slimtf.contrib.layers定義的網絡的權重。使用tf slim或tf圖層的摘要

舉例來說,如果我有:

net = slim.conv2d(net, ...) 

如何我可以添加的權重和偏置成一個總結?

編輯:我剛纔看到我可以使用tf.contrib.layers.summarize_collection。這可能適用於我想要做的事情。

回答

7

這是我深入調查後發現的解決方案,以防某人遇到同樣的問題。

對於tf.contrib.slim,(不推薦)的權重被添加到收藏tf.GraphKeys.TRAINABLE_VARIABLES可以與可視化:

tf.contrib.layers.summarize_collection(tf.GraphKeys.TRAINABLE_VARIABLES) 

tf.contrib.layers,還有一些方便的方法

tf.contrib.layers.summarize_weights() # tf.GraphKeys.WEIGHTS 
tf.contrib.layers.summarize_biases() # tf.GraphKeys.BIASES 
# For tf >= 1.3: 
tf.contrib.layers.summarize_tensors() 

爲了更好地控制哪些變量添加,可以通過自定義代碼summarize_collection

+0

'tf.contrib.layers.summarize_weights()#tf.GraphKeys.WEIGHTS tf.contrib.layers.summarize_biases()#tf.GraphKeys.BIASES' 從tensorflow模塊移除。你能否更新答案? – Yanagiba

+2

我想這個問題可以用'tf.contrib.layers.summarize_tensors()'來更新。 – juliohm