I cannot not find how to add a summary to visualize weights for networks which have been defined with tf.contrib.slim
or tf.contrib.layers
.
For instance, if I have:
net = slim.conv2d(net, ...)
How can I add the weights and bias into a summary ?
Edit: I just saw that I could use tf.contrib.layers.summarize_collection
. That probably works for what I want to do.
Here is the solution I found after deeper investigation, in case someone has the same problem than me.
For tf.contrib.slim
, (deprecated) the weights are added to the collection tf.GraphKeys.TRAINABLE_VARIABLES
which can be visualized with:
tf.contrib.layers.summarize_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
For tf.contrib.layers
, there are some convenience methods
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()
To have a better control on which variables add, it's possible by customizing the code of summarize_collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With