+ 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])

4th Mar 2021, 11:26 AM
Paulina Markiewicz
2 Réponses
+ 1
26th Mar 2021, 12:24 PM
MohammadMahdi
MohammadMahdi - avatar
+ 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
7th Apr 2021, 7:06 PM
Paulina Markiewicz