I had read the documentation and tried to understand how to work with scipy.optimize.minimize()
, but I can not.
from scipy.optimize import minimize
def f(x):
return x**2
x0 = [-2.0, -1.0, 0.0, 1.0, 2.0]
res = minimize(f, x0)
print(res.x)
Output: "ValueError: The user-provided objective function must return a scalar value."
I have solve it: x0 should be a number or (1,) array