Search code examples
pythonscipyscipy-optimize

Where is the square operation "fun**2" in the source code of “scipy.optimize.least_squares”?


Now I need to add the regularization term to “scipy.optimize.least_squares”. Could anyone tell me where is the square operation "fun**2" in the source code of scipy?

scipy.optimize.least_squares(fun, x0,...)


Solution

  • In the function loss_function, lines 219-226 or 228-235 depending on whether or not the loss parameter is itself a callable. This function is called at line 826, after being gotten at line 824.