In my Matlab code, I am using customize training loop for my algorithm, so I am using forward and dlgradient to create my loss and gradient models, and then taking them by dlfeval.
I am going to ask you, is there any way to calculate the Hessian model of the objective function (in my case softmax cross entropy) in the training loop? Something similar dlgradent, lets say.
Actually, if I find the way of computing Hessian, I can take some strategies to solve this problem, storing issue. I am going to do computations layer by layer. In this case, the size of Hessian matrix, depends on only to the number of that specific layter. So it would noy be too large if it is considered per layer.
You can use hessian function to find hessian matrix.
hessian(f,v)finds theHessian matrixof the symbolic scalar functionfwith respect to vectorvin Cartesian coordinates.
If we do not specifyv, thenhessian(f)finds the Hessian matrix of the scalar functionfwith respect to a vector constructed from all symbolic variables found inf.
Adding a example below
syms x y z
f = x*y + 2*z*x;
hessian(f,[x,y,z])
ans =
Adding the MATLAB documentation link so that you can dive deeper:
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.