Open deepers opened 6 years ago
It seems like this bug occurs when you pass in a list as one of the items being concatenated. If you first wrap the list in an array, then everything is fine.
(deepee) deepee@entropy:~$ cat concatenate.py
from autograd import jacobian, numpy as anp
import numpy
def f(x):
return anp.concatenate([anp.array([x[0]])])
print(f(anp.array([1.])))
print(f(anp.array([2.])))
print(jacobian(f)(anp.array([1.])))
print(jacobian(f)(anp.array([2.])))
(deepee) deepee@entropy:~$ python concatenate.py
[1.]
[2.]
[[1.]]
[[1.]]
Thanks for raising this. This bug would also occur with tuples and is a result of the fact that concatenate only descends one level into (nested) tuples and lists looking for things to differentiate w.r.t.
Since the argument you’re passing to concatenate is a nested list it doesn’t get picked up. We are working on some changes to the Autograd core that will make this easy to fix. Hopefully should be merged soon. On Fri, 18 May 2018 at 09:01, deepers notifications@github.com wrote:
It seems like this bug occurs when you pass in a list as one of the items being concatenated. If you first wrap the list in an array, then everything is fine.
(deepee) deepee@entropy:~$ cat concatenate.py from autograd import jacobian, numpy as anp import numpy
def f(x): return anp.concatenate([anp.array([x[0]])])
print(f(anp.array([1.]))) print(f(anp.array([2.]))) print(jacobian(f)(anp.array([1.]))) print(jacobian(f)(anp.array([2.])))
(deepee) deepee@entropy:~$ python concatenate.py [1.] [2.] [[1.]] [[1.]]
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HIPS/autograd/issues/399#issuecomment-390253774, or mute the thread https://github.com/notifications/unsubscribe-auth/AOjgu7BuBqT0Oc0am7OFWm5i14QLCzekks5tzvBjgaJpZM4UDlFv .
Awesome! Thanks @j-towns! Deepee
I seem to be getting the wrong answer when I compute the Jacobian of a function defined using concatenate. The Jacobian of the function below should be always be
[[1]]
but it's coming out[[0]]
. I'm running off the master branch of autograd.Thanks, Deepee