Skip to content

Commit

Permalink
Move weights to be the second argument in tf.bincount.
Browse files Browse the repository at this point in the history
This matches np.bincount(x, weights, minlength).
Change: 153476565
  • Loading branch information
ringw authored and Amit Patankar committed Apr 20, 2017
1 parent dfcbf51 commit 498f3f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tensorflow/python/kernel_tests/bincount_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def test_random_with_weights(self):
else:
weights = np.random.random(num_samples)
self.assertAllEqual(
math_ops.bincount(arr, weights=weights).eval(),
math_ops.bincount(arr, weights).eval(),
np.bincount(arr, weights))

def test_zero_weights(self):
with self.test_session():
self.assertAllEqual(
math_ops.bincount(np.arange(1000), weights=np.zeros(1000)).eval(),
math_ops.bincount(np.arange(1000), np.zeros(1000)).eval(),
np.zeros(1000))

def test_negative(self):
Expand Down
8 changes: 4 additions & 4 deletions tensorflow/python/ops/math_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2026,9 +2026,9 @@ def tanh(x, name=None):


def bincount(arr,
weights=None,
minlength=None,
maxlength=None,
weights=None,
dtype=dtypes.int32):
"""Counts the number of occurrences of each value in an integer array.
Expand All @@ -2040,13 +2040,13 @@ def bincount(arr,
Args:
arr: An int32 tensor of non-negative values.
weights: If non-None, must be the same shape as arr. For each value in
`arr`, the bin will be incremented by the corresponding weight instead
of 1.
minlength: If given, ensures the output has length at least `minlength`,
padding with zeros at the end if necessary.
maxlength: If given, skips values in `arr` that are equal or greater than
`maxlength`, ensuring that the output has length at most `maxlength`.
weights: If non-None, must be the same shape as arr. For each value in
`arr`, the bin will be incremented by the corresponding weight instead
of 1.
dtype: If `weights` is None, determines the type of the output bins.
Returns:
Expand Down

0 comments on commit 498f3f6

Please sign in to comment.