Gradient of L2-norm using dlgradient

3 次查看(过去 30 天)
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