gpt4 book ai didi

algorithm - fminunc 的 Matlab 函数梯度

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:04:25 26 4
gpt4 key购买 nike

f = @(w) sum(log(1 + exp(-t .* (phis * w'))))/size(phis, 1) + coef * w*w';
options = optimset('Display', 'notify', 'MaxFunEvals', 2e+6, 'MaxIter', 2e+6);
w = fminunc(f, ones(1, size(phis, 2)), options);
  • ph 大小为 NxN+1
  • t 大小为 Nx1
  • coef 是常量

我试图最小化函数 f,首先我使用的是 fminsearch 但它工作了很长时间,这就是为什么现在我使用 fminunc ,但有一个问题:我需要函数梯度来加速。你能帮我构造函数 f 的梯度吗,因为我总是收到这个警告:

Warning: Gradient must be provided for trust-region algorithm;
using line-search algorithm instead.

最佳答案

您尝试做的是逻辑回归,具有 L2 正则化。有比调用 Matlab 函数更好的方法来解决这个问题,因为对数似然函数是凹函数。

您应该在 the statistical website 中提问,或查看 my former question there .

关于algorithm - fminunc 的 Matlab 函数梯度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7080111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com