Gradient of L2-norm using dlgradient

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

 Akzeptierte Antwort

Matt J
Matt J am 26 Okt. 2022
Bearbeitet: Matt J am 26 Okt. 2022

0 Stimmen

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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Report Generator finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022a

Gefragt:

am 26 Okt. 2022

Bearbeitet:

am 26 Okt. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by