+ 1
Gradient of second order for ml
I wrote this piece of code for calculating gradient of second order (I need it for newton's gradient descent method, don't tell me to use different method, cause I have to implement this certain methkd). Can I use it? Or it will not produce the correct solution? If so, what should I change? Example of code for some y=x^2+3 for some arbitrary x import numdifftools as nd y = lambda x: x**2+3 grad1 = lambda x: nd.Gradient(y)([x]) grad2 = nd.Gradient(grad1)([x])
2 ответов
+ 1
See this
Probably help u
https://pypi.org/project/numdifftools/
+ 2
I have already solved the problem. Just used gradient function from scipy module
The given by me code was working, but only for one dimension. For equations with more dimensions than one, results were not correct