Hessian by DL toolbox

조회 수: 4 (최근 30일)
MAHSA YOUSEFI
MAHSA YOUSEFI 2021년 9월 27일
답변: Anurag Ojha 2024년 5월 6일
Hi there.
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.
Thank you...
  댓글 수: 3
MAHSA YOUSEFI
MAHSA YOUSEFI 2021년 9월 27일
3.500,000 parameters totally and a dataset with 50,000 samples. For sure, yes! It would be a large matrix.
In my Algorithm, I have a subsampled Hessian (10,000 samples) multiply by a vectore.
MAHSA YOUSEFI
MAHSA YOUSEFI 2021년 9월 27일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Anurag Ojha
Anurag Ojha 2024년 5월 6일
Hello Mahsa
You can use hessian function to find hessian matrix.
hessian(f,v) finds the Hessian matrix of the symbolic scalar function f with respect to vector v in Cartesian coordinates.
If we do not specify v, then hessian(f) finds the Hessian matrix of the scalar function f with respect to a vector constructed from all symbolic variables found in f.
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:

카테고리

Help CenterFile Exchange에서 Custom Training Loops에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by