As said in the title, I want to convert from Autograd ArrayBox to BigFloat.
My function is simple:
def fun(mean, variance, bin_mean, bin_variance):
first = np.float(bf.sqrt(1.0 * bin_variance / (bin_variance + variance)))
second_numerator = (bin_mean - mean)**2
second_denominator = 2*(bin_variance + variance)
second = np.float(bf.exp(-second_numerator/second_denominator))
return first * second
and I need high precision and hence I want to use bigfloat package. Now, this function is part of a more complex one for which I'm using scipy.optimize.minimize
function for finding the minimum of the function while also using autograd
to approximate Jacobian and Hessian matrices.
The error I'm getting when I run my code is
TypeError: Unable to convert argument Autograd ArrayBox with value 0.01297563222656762 of type <class 'autograd.numpy.numpy_boxes.ArrayBox'> to BigFloat
So my question is: how to convert from Autograd's ArrayBox to BigFloat? How to even properly extract the value inside the ArrayBox?
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