# tf.math.zero_fraction

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/math/zero_fraction) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/ops/nn_impl.py#L669-L707) |

Returns the fraction of zeros in `value`.

#### View aliases


**Main aliases**

[`tf.nn.zero_fraction`](https://www.tensorflow.org/api_docs/python/tf/math/zero_fraction)
**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.math.zero_fraction`](https://www.tensorflow.org/api_docs/python/tf/math/zero_fraction), [`tf.compat.v1.nn.zero_fraction`](https://www.tensorflow.org/api_docs/python/tf/math/zero_fraction), \`tf.compat.v2.math.zero_fraction\`, \`tf.compat.v2.nn.zero_fraction\`

<br />

    tf.math.zero_fraction(
        value, name=None
    )

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

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

        z = tf.nn.relu(...)
        summ = tf.compat.v1.summary.scalar('sparsity', tf.nn.zero_fraction(z))

<br />

<br />

<br />

| ## Args ||
|---|---|
| `value` | A tensor of numeric type. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The fraction of zeros in `value`, with type `float32`. ||

<br />