Merge pull request #38958 from yongtang:histogram-doc

PiperOrigin-RevId: 313240146
Change-Id: I7baa94b94466583d119f74dc3a6f2b540aebe4f0
This commit is contained in:
TensorFlower Gardener 2020-05-26 12:05:27 -07:00
commit e76bff1201

View File

@ -64,17 +64,14 @@ def histogram_fixed_width_bins(values,
Examples:
```python
# 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.compat.v1.get_default_session() as sess:
indices = tf.histogram_fixed_width_bins(new_values, value_range, nbins=5)
variables.global_variables_initializer().run()
sess.run(indices) # [0, 0, 1, 2, 4, 4]
```
>>> # 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]
>>> indices = tf.histogram_fixed_width_bins(new_values, value_range, nbins=5)
>>> indices.numpy()
array([0, 0, 1, 2, 4, 4], dtype=int32)
"""
with ops.name_scope(name, 'histogram_fixed_width_bins',
[values, value_range, nbins]):
@ -134,17 +131,14 @@ def histogram_fixed_width(values,
Examples:
```python
# 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.compat.v1.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]
```
>>> # 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)
"""
with ops.name_scope(name, 'histogram_fixed_width',
[values, value_range, nbins]) as name: