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
When I run :
import autograd.numpy as npa
a = npa.ones((7,7))
b = 2 * npa.ones((3,3))
a[2:5, 3:6] = b.flatten().reshape((3,3))
def objective(b):
a[2:5, 3:6] = b.flatten().reshape((3,3))
acs = sum(rhoxy)
return acs
objective_jac = jacobian(objective, mode='reverse')
aa = objective_jac(b)
I will get this error:
TypeError Traceback (most recent call last)
TypeError: float() argument must be a string or a number, not 'ArrayBox'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
in
8 return acs
9 objective_jac = jacobian(objective, mode='reverse')
---> 10 aa = objective_jac(b)
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\wrap_util.py in nary_f(*args, **kwargs)
18 else:
19 x = tuple(args[i] for i in argnum)
---> 20 return unary_operator(unary_f, x, *nary_op_args, **nary_op_kwargs)
21 return nary_f
22 return nary_operator
D:\CEVICHE\ceviche\jacobians.py in jacobian_reverse(fun, x)
30 def jacobian_reverse(fun, x):
31 """ Compute jacobian of fun with respect to x using reverse mode differentiation"""
---> 32 vjp, ans = make_vjp(fun, x)
33 grads = map(vjp, vspace(ans).standard_basis())
34 m, n = _jac_shape(x, ans)
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\core.py in make_vjp(fun, x)
8 def make_vjp(fun, x):
9 start_node = VJPNode.new_root()
---> 10 end_value, end_node = trace(start_node, fun, x)
11 if end_node is None:
12 def vjp(g): return vspace(x).zeros()
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\tracer.py in trace(start_node, fun, x)
8 with trace_stack.new_trace() as t:
9 start_box = new_box(x, t, start_node)
---> 10 end_box = fun(start_box)
11 if isbox(end_box) and end_box._trace == start_box._trace:
12 return end_box._value, end_box._node
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\wrap_util.py in unary_f(x)
13 else:
14 subargs = subvals(args, zip(argnum, x))
---> 15 return fun(*subargs, **kwargs)
16 if isinstance(argnum, int):
17 x = args[argnum]
When I run :
import autograd.numpy as npa
a = npa.ones((7,7))
b = 2 * npa.ones((3,3))
a[2:5, 3:6] = b.flatten().reshape((3,3))
def objective(b):
a[2:5, 3:6] = b.flatten().reshape((3,3))
acs = sum(rhoxy)
return acs
objective_jac = jacobian(objective, mode='reverse')
aa = objective_jac(b)
I will get this error:
TypeError Traceback (most recent call last)
TypeError: float() argument must be a string or a number, not 'ArrayBox'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
in
8 return acs
9 objective_jac = jacobian(objective, mode='reverse')
---> 10 aa = objective_jac(b)
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\wrap_util.py in nary_f(*args, **kwargs)
18 else:
19 x = tuple(args[i] for i in argnum)
---> 20 return unary_operator(unary_f, x, *nary_op_args, **nary_op_kwargs)
21 return nary_f
22 return nary_operator
D:\CEVICHE\ceviche\jacobians.py in jacobian_reverse(fun, x)
30 def jacobian_reverse(fun, x):
31 """ Compute jacobian of fun with respect to x using reverse mode differentiation"""
---> 32 vjp, ans = make_vjp(fun, x)
33 grads = map(vjp, vspace(ans).standard_basis())
34 m, n = _jac_shape(x, ans)
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\core.py in make_vjp(fun, x)
8 def make_vjp(fun, x):
9 start_node = VJPNode.new_root()
---> 10 end_value, end_node = trace(start_node, fun, x)
11 if end_node is None:
12 def vjp(g): return vspace(x).zeros()
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\tracer.py in trace(start_node, fun, x)
8 with trace_stack.new_trace() as t:
9 start_box = new_box(x, t, start_node)
---> 10 end_box = fun(start_box)
11 if isbox(end_box) and end_box._trace == start_box._trace:
12 return end_box._value, end_box._node
D:\Anaconda3\envs\ceviche\lib\site-packages\autograd-1.3-py3.7.egg\autograd\wrap_util.py in unary_f(x)
13 else:
14 subargs = subvals(args, zip(argnum, x))
---> 15 return fun(*subargs, **kwargs)
16 if isinstance(argnum, int):
17 x = args[argnum]
in objective(b)
4 a[2:5, 3:6] = b.flatten().reshape((3,3))
5 def objective(b):
----> 6 a[2:5, 3:6] = b.flatten().reshape((3,3))
7 acs = sum(rhoxy)
8 return acs
ValueError: setting an array element with a sequence.
The text was updated successfully, but these errors were encountered: