tf.raw_ops.HistogramFixedWidth

Return histogram of values.

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

# 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]

with tf.get_default_session() as sess:
  hist = tf.histogram_fixed_width(new_values, value_range, nbins=5)
  variables.global_variables_initializer().run()
  sess.run(hist) => [2, 1, 1, 0, 2]
Args
values A Tensor. Must be one of the following types: int32, int64, float32, float64. Numeric Tensor.
value_range A Tensor. Must have the same type as values. 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 A Tensor of type int32. Scalar int32 Tensor. Number of histogram bins.
dtype An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int32.
name A name for the operation (optional).
Returns
A Tensor of type dtype.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/raw_ops/HistogramFixedWidth