I would like to minimize the following cost function
where h_u and h_v are the vectors of real numbers.
I am doing this in Python, but I am not sure that the function minimize
from scipy.optimize
package is what I need.
My approach is the following:
given h_u
and h_v
as two matrices with dimensionality
print(h_u.shape, h_v.shape)
>>>(12458, 7) (12458, 7)
I define objective function
fun = lambda h: (h[0]*h[1]).mean()
Then I stack the vectors
h_in = np.stack((h_u, h_v), axis = 0)
and try to minimize
minimized = minimize(fun, x0 = h_in)
I am not sure that providing h_in
as an initial guess x0
is correct, because it produces an error
MemoryError: Unable to allocate 227. GiB for an array with shape (174412, 174412) and data type float64
Could somebody tell me if I do it correctly and how could I circumvent the error? Thank you!