Beispiel #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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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
def sg_summary_param(tensor, prefix=None, name=None):
    r"""Register `tensor` to summary report as `parameters`

    Args:
      tensor: A `Tensor` to log as parameters
      prefix: A `string`. A prefix to display in the tensor board web UI.
      name: A `string`. A name to display in the tensor board web UI.

    Returns:
      None
    """
    # defaults
    prefix = '' if prefix is None else prefix + '/'
    # summary name
    name = prefix + _pretty_name(tensor) if name is None else prefix + name
    # summary statistics
    # noinspection PyBroadException
    try:
        tf.summary.scalar(name + '/norm', tf.global_norm([tensor]))
        tf.summary.histogram(name + '/norm-h', tensor)
    except:
        pass
def sg_summary_gradient(tensor, gradient, prefix=None, name=None):
    r"""Register `tensor` to summary report as `gradient`

    Args:
      tensor: A `Tensor` to log as gradient
      gradient: A 0-D `Tensor`. A gradient to log
      prefix: A `string`. A prefix to display in the tensor board web UI.
      name: A `string`. A name to display in the tensor board web UI.

    Returns:
        None
    """
    # defaults
    prefix = '' if prefix is None else prefix + '/'
    # summary name
    name = prefix + _full_name(tensor) if name is None else prefix + name
    # summary statistics
    # noinspection PyBroadException
    try:
        tf.summary.scalar(name + '/grad', tf.global_norm([gradient]))
        tf.summary.histogram(name + '/grad-h', gradient)
    except:
        pass