Пример #1
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)
Пример #2
0
def sg_leaky_relu(x, opt):
    r""""See [Xu, et al. 2015](https://arxiv.org/pdf/1505.00853v2.pdf)

    Args:
        x: A tensor
        opt:
          name: A name for the operation (optional).
    
    Returns:
      A `Tensor` with the same type and shape as `x`.
    """
    return tf.select(tf.greater(x, 0), x, 0.01 * x, name=opt.name)
Пример #3
0
def sg_summary_activation(tensor, prefix=None, name=None):
    r"""Register `tensor` to summary report as `activation`

    Args:
      tensor: A `Tensor` to log as activation
      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
    _scalar(name + '/ratio',
            tf.reduce_mean(tf.cast(tf.greater(tensor, 0), tf.sg_floatx)))
    _histogram(name + '/ratio-h', tensor)
Пример #4
0
def sg_leaky_relu(x, opt):
    return tf.select(tf.greater(x, 0), x, 0.01 * x, name=opt.name)
Пример #5
0
def sg_leaky_relu(x, opt):
    r""""See Xu, et al. 2015 `https://arxiv.org/pdf/1505.00853v2.pdf`
    """
    return tf.select(tf.greater(x, 0), x, 0.01 * x, name=opt.name)