Accessing Autograd Arraybox Values

I am trying to use the python package autograd and I want to use values of an autograd arraybox in an interpolation

np.interp(x, x_values, y_values)

where y_values are store in an autograd arraybox. This leads to an error

TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'

which is connected to the fact the y_values is an autograd arraybox. I don't understand why I get this error, since I thought that autograd should work with numpy? But ok if I can convert the autograd arraybox into a numpy array I can work with that, but that does not seem to work either?

floats = [float(x) for x in y_values]

leads to

TypeError: float() argument must be a string or a number, not 'ArrayBox'
1

1 Answer

I did:

myvariable._value

and I got an array with the values inside the ArrayBox, which then I could manipulate.

I figured it out after checking the attributes of the ArrayBox using call(myvariable). Looks it is not documented anywhere. Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest