def sg_summary_param(tensor, prefix='40. parameters'): # defaults prefix = '' if prefix is None else prefix + '/' # summary name name = prefix + _pretty_name(tensor) # summary statistics with tf.name_scope('summary'): tf.scalar_summary(name + '/norm', tf.global_norm([tensor])) tf.histogram_summary(name, tensor)
def sg_summary_metric(tensor, prefix='20. metric'): # defaults prefix = '' if prefix is None else prefix + '/' # summary name name = prefix + _pretty_name(tensor) # summary statistics with tf.name_scope('summary'): tf.scalar_summary(name + '/avg', tf.reduce_mean(tensor)) tf.histogram_summary(name, tensor)
def sg_summary_gradient(tensor, gradient, prefix='50. gradient'): # defaults prefix = '' if prefix is None else prefix + '/' # summary name name = prefix + _pretty_name(tensor) # summary statistics with tf.name_scope('summary'): tf.scalar_summary(name + '/norm', tf.global_norm([gradient])) tf.histogram_summary(name, gradient)
def sg_summary_metric(tensor, prefix='20. metric'): r"""Writes the average of `tensor` (=metric such as accuracy). """ # defaults prefix = '' if prefix is None else prefix + '/' # summary name name = prefix + _pretty_name(tensor) # summary statistics with tf.name_scope('summary'): tf.scalar_summary(name + '/avg', tf.reduce_mean(tensor)) tf.histogram_summary(name, tensor)
def sg_summary_activation(tensor, prefix='30. activation'): # defaults prefix = '' if prefix is None else prefix + '/' # summary name name = prefix + _pretty_name(tensor) # summary statistics with tf.name_scope('summary'): tf.scalar_summary(name + '/norm', tf.global_norm([tensor])) tf.scalar_summary( name + '/ratio', tf.reduce_mean(tf.cast(tf.greater(tensor, 0), tf.sg_floatx))) tf.histogram_summary(name, tensor)
def sg_summary_gradient(tensor, gradient, prefix='50. gradient'): r"""Writes the normalized gradient value Args: tensor: A `Tensor` variable. gradient: A `Tensor`. Gradient of `tensor`. """ # defaults prefix = '' if prefix is None else prefix + '/' # summary name name = prefix + _pretty_name(tensor) # summary statistics with tf.name_scope('summary'): try: tf.scalar_summary(name + '/norm', tf.global_norm([gradient])) tf.histogram_summary(name, gradient) except: pass