Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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