def zero_fraction(value, name=None):
    "Returns the fraction of zeros in `value`.\n\n  If `value` is empty, the result is `nan`.\n\n  This is useful in summaries to measure and report sparsity.  For example,\n\n      z = tf.Relu(...)\n      summ = tf.scalar_summary('sparsity', tf.nn.zero_fraction(z))\n\n  Args:\n    value: A tensor of numeric type.\n    name: A name for the operation (optional).\n\n  Returns:\n    The fraction of zeros in `value`, with type `float32`.\n  "
    with ops.op_scope([value], name, 'zero_fraction'):
        value = ops.convert_to_tensor(value, name='value')
        zero = constant_op.constant(0, dtype=value.dtype, name='zero')
        return math_ops.reduce_mean(math_ops.cast(math_ops.equal(value, zero), dtypes.float32))
Returns the fraction of zeros in `value`.

If `value` is empty, the result is `nan`.

This is useful in summaries to measure and report sparsity.  For example,

    z = tf.Relu(...)
    summ = tf.scalar_summary('sparsity', tf.nn.zero_fraction(z))

Args:
  value: A tensor of numeric type.
  name: A name for the operation (optional).

Returns:
  The fraction of zeros in `value`, with type `float32`.
def zero_fraction(value, name=None):
    "Returns the fraction of zeros in `value`.\n\n  If `value` is empty, the result is `nan`.\n\n  This is useful in summaries to measure and report sparsity.  For example,\n\n      z = tf.Relu(...)\n      summ = tf.scalar_summary('sparsity', tf.nn.zero_fraction(z))\n\n  Args:\n    value: A tensor of numeric type.\n    name: A name for the operation (optional).\n\n  Returns:\n    The fraction of zeros in `value`, with type `float32`.\n  "
    with ops.op_scope([value], name, 'zero_fraction'):
        value = ops.convert_to_tensor(value, name='value')
        zero = constant_op.constant(0, dtype=value.dtype, name='zero')
        return math_ops.reduce_mean(math_ops.cast(math_ops.equal(value, zero), dtypes.float32))