I'm having trouble getting anything to work the way I'm defining my functions, i…t's probably user error, but my example is terse.
I'm just trying to define a simple neural network and keep running into issues using `np.tanh()` or `np.exp()` and the only similar errors I could find are from having nested data structures, which I don't have.
Here's my full code snippet:
```
import autograd.numpy as np
from autograd import grad
action_dim = 2
feature_dim = 6
layer_dim = 4
w1 = np.random.rand(feature_dim, layer_dim)
b1 = np.random.rand(layer_dim)
w2 = np.random.rand(layer_dim, action_dim)
b2 = np.random.rand(action_dim)
def continuous_policy_function(w1, b1, w2, b2):
x = observation.dot(w1) + b1
x = 1.0 / (1.0 + np.exp(-x)) # sigmoid "squashing" function to interval [0,1]
out = x.dot(w2) + b2
return out
grad_function = grad(continuous_policy_function)
observation = np.random.rand(feature_dim)
action = continuous_policy_function(w1, b1, w2, b2)
print(grad_function(w1, b1, w2, b2))
```
and the full trace:
```
Traceback (most recent call last):
File "annoying_autograd.py", line 55, in <module>
print(grad_function(w1, b1, w2, b2))
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/autograd/wrap_util.py", line 20, in nary_f
return unary_operator(unary_f, x, *nary_op_args, **nary_op_kwargs)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/autograd/differential_operators.py", line 24, in grad
vjp, ans = _make_vjp(fun, x)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/autograd/core.py", line 10, in make_vjp
end_value, end_node = trace(start_node, fun, x)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/autograd/tracer.py", line 10, in trace
end_box = fun(start_box)
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/autograd/wrap_util.py", line 15, in unary_f
return fun(*subargs, **kwargs)
File "annoying_autograd.py", line 29, in continuous_policy_function
x = 1.0 / (1.0 + np.exp(-x)) # sigmoid "squashing" function to interval [0,1]
File "/usr/local/Cellar/python3/3.6.4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/autograd/tracer.py", line 48, in f_wrapped
return f_raw(*args, **kwargs)
AttributeError: 'ArrayBox' object has no attribute 'exp'
```
I'm using Python 3.6.4 and and autograd 1.2 which I pulled from pip this morning.
Please let me know what I'm doing wrong here! :)