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

 採用された回答

Matt J
Matt J 2022 年 10 月 26 日
編集済み: Matt J 2022 年 10 月 26 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Report Generator についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 10 月 26 日

編集済み:

2022 年 10 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by