Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array dimension expansion causes segfault #72

Closed
kswersky opened this issue Nov 11, 2015 · 5 comments
Closed

Array dimension expansion causes segfault #72

kswersky opened this issue Nov 11, 2015 · 5 comments
Labels

Comments

@kswersky
Copy link

import numpy as np
from autograd import grad
def fun(x):
    return x[:, None].sum()
g = grad(fun)
g(np.random.randn(5))

Causes a seg fault. There are other ways to expand the dimensions of an array other than [:, None], but perhaps it should fail more gracefully in this case. I've also verified that it does the same thing with np.newaxis.

@kswersky kswersky added the bug label Nov 11, 2015
@dougalm
Copy link
Contributor

dougalm commented Nov 11, 2015

Both x[:, None] and x[:, np.newaxis] are valid ways to expand dimensions and autograd has always supported them. I can't reproduce the segfault on my machine. What versions of numpy and scipy are you using?

@kswersky
Copy link
Author

Numpy 1.8.0 and Scipy 0.13. Looks like I should upgrade!

@mattjj
Copy link
Contributor

mattjj commented Nov 11, 2015

The segfault happens on numpy 1.8.0, 1.8.1, and 1.8.2, but not 1.9.0. Maybe autograd should require numpy>=1.9 (or we could find the bug and work around it).

@mattjj
Copy link
Contributor

mattjj commented Nov 11, 2015

Oh, numpy's setup.py does require >=1.9 already.

@mattjj mattjj closed this as completed Nov 11, 2015
@mattjj
Copy link
Contributor

mattjj commented Nov 11, 2015

Btw, the segfault happens in np.add.at in primitive_sum_arrays when called with these arguments:

ipdb> print new_array
[ 0.  0.  0.  0.  0.]
ipdb> print array.idx
(slice(None, None, None), None)
ipdb> print array.val
[[ 1.]
 [ 1.]
 [ 1.]
 [ 1.]
 [ 1.]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants