Created
February 24, 2017 19:51
-
-
Save alexbw/4da3e71eb9b59b7551b9bb8a535f2ef7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python | |
def f(x): | |
return np.sum(x) | |
grad(f)(np.eye(3)) | |
``` | |
```python | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-2-a3386d50981f> in <module>() | |
1 def f(x): | |
2 return np.sum(x) | |
----> 3 grad(f)(np.eye(3)) | |
/Users/alexbw/Code/autograd/autograd/convenience_wrappers.py in gradfun(*args, **kwargs) | |
24 args[argnum] = safe_type(args[argnum]) | |
25 vjp, ans = make_vjp(scalar_fun, argnum)(*args, **kwargs) | |
---> 26 return vjp(cast_to_same_dtype(1.0, ans)) | |
27 | |
28 return gradfun | |
/Users/alexbw/Code/autograd/autograd/core.py in <lambda>(g) | |
16 warnings.warn("Output seems independent of input.") | |
17 return lambda g : start_node.vspace.zeros(), end_node | |
---> 18 return lambda g : backward_pass(g, end_node, start_node), end_node | |
19 return vjp | |
20 | |
/Users/alexbw/Code/autograd/autograd/core.py in backward_pass(g, end_node, start_node) | |
39 for argnum, parent in parents: | |
40 outgrad = function.vjp(argnum, cur_outgrad, node, | |
---> 41 parent.vspace, node.vspace, args, kwargs) | |
42 outgrads[parent].append(outgrad) | |
43 assert_vspace_match(outgrad, parent.vspace, function) | |
/Users/alexbw/Code/autograd/autograd/core.py in vjp(self, argnum, outgrad, ans, vs, gvs, args, kwargs) | |
76 def vjp(self, argnum, outgrad, ans, vs, gvs, args, kwargs): | |
77 try: | |
---> 78 return self.vjps[argnum](outgrad, ans, vs, gvs, *args, **kwargs) | |
79 except KeyError: | |
80 if self.vjps == {}: | |
TypeError: grad_np_sum() got an unexpected keyword argument 'dtype' | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment