# tf.histogram_fixed_width

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/histogram_fixed_width) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/ops/histogram_ops.py#L102-L147) |

Return histogram of values.

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.histogram_fixed_width`](https://www.tensorflow.org/api_docs/python/tf/histogram_fixed_width)

<br />

    tf.histogram_fixed_width(
        values, value_range, nbins=100, dtype=tf.dtypes.int32, name=None
    )

Given the tensor `values`, this operation returns a rank 1 histogram counting
the number of entries in `values` that fell into every bin. The bins are
equal width and determined by the arguments `value_range` and `nbins`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `values` | Numeric `Tensor`. |
| `value_range` | Shape \[2\] `Tensor` of same `dtype` as `values`. values \<= value_range\[0\] will be mapped to hist\[0\], values \>= value_range\[1\] will be mapped to hist\[-1\]. |
| `nbins` | Scalar `int32 Tensor`. Number of histogram bins. |
| `dtype` | dtype for returned histogram. |
| `name` | A name for this operation (defaults to 'histogram_fixed_width'). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A 1-D `Tensor` holding histogram of values. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If any unsupported dtype is provided. |
| [`tf.errors.InvalidArgumentError`](https://www.tensorflow.org/api_docs/python/tf/errors/InvalidArgumentError) | If value_range does not satisfy value_range\[0\] \< value_range\[1\]. |

<br />

#### Examples:

    # Bins will be:  (-inf, 1), [1, 2), [2, 3), [3, 4), [4, inf)

    nbins = 5
    value_range = [0.0, 5.0]
    new_values = [-1.0, 0.0, 1.5, 2.0, 5.0, 15]
    hist = tf.histogram_fixed_width(new_values, value_range, nbins=5)
    hist.numpy()
    array([2, 1, 1, 0, 2], dtype=int32)