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

Error: float() argument must be a string or a number, not 'ArrayBox' #559

Open
kaipengliuHIT opened this issue Jul 30, 2020 · 0 comments
Open

Comments

@kaipengliuHIT
Copy link

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.

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

No branches or pull requests

2 participants
@kaipengliuHIT and others