You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for making autograd! It's been extremely useful.
I noticed though that np.take produces the wrong result if the index array contains duplicate values. For example, quick_grad_check(lambda x: np.sum(x[[0,0]]), np.array([1.]))
fails with: AssertionError: Check failed! nd=2.0, ad=1.0
You can fix it by changing a line in primitive_sum_arrays (in numpy_extra.py) from new_array[array.idx] += array.val
to: numpy.add.at(new_array, array.idx, array.val). I'm not sure if this error occurs elsewhere, but it seems to at least fix the problem in all of the cases that I've tried.
The text was updated successfully, but these errors were encountered:
Hi,
First of all, thanks for making autograd! It's been extremely useful.
I noticed though that np.take produces the wrong result if the index array contains duplicate values. For example,
quick_grad_check(lambda x: np.sum(x[[0,0]]), np.array([1.]))
fails with:
AssertionError: Check failed! nd=2.0, ad=1.0
You can fix it by changing a line in
primitive_sum_arrays
(innumpy_extra.py
) fromnew_array[array.idx] += array.val
to:
numpy.add.at(new_array, array.idx, array.val)
. I'm not sure if this error occurs elsewhere, but it seems to at least fix the problem in all of the cases that I've tried.The text was updated successfully, but these errors were encountered: