Gradient of L2-norm using dlgradient

조회 수: 3 (최근 30일)
reza
reza 2022년 10월 26일
편집: Matt J 2022년 10월 26일
Is it possible to compute the gradient of n = norm(X,"fro") using dlgradient() ?
function y = f(x,theta)
y = norm(x-theta, "fro");
end
function [y, dy] = fun_and_deriv(x,theta)
y = f(x,theta);
dy = dlgradient(y,theta);
end

채택된 답변

Matt J
Matt J 2022년 10월 26일
편집: Matt J 2022년 10월 26일
Why do that, when the gradient is analytically known?
function [y, dy] = fun_and_deriv(x,theta)
delta=theta-x;
y = norm(delta, "fro");
dy = delta./y;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by