简体   繁体   English

用于 fminunc 的 Matlab function 梯度

[英]Matlab function gradient for fminunc

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);
  • phis size is NxN+1 phis大小为 NxN+1
  • t size is Nx1 t大小为 Nx1
  • coef is const coef是常量

I'm trying to minimize function f , firstly I was using fminsearch but it works long time, that's why now I use fminunc , but there is one problem: I need function gradient for acceleration.我试图最小化 function f ,首先我使用fminsearch但它工作很长时间,这就是为什么现在我使用fminunc ,但有一个问题:我需要 function 梯度来加速。 Can you help me please construct gradient for function f , coz I always get this warning:你能帮我为 function f构建渐变吗,因为我总是收到这个警告:

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

What you are trying to do is called logistic regression, with a L2-regularization .您正在尝试做的事情称为逻辑回归,带有 L2-regularization There are far better ways to solve this problem than a call to a Matlab function, since the log-likelihood function is concave.有比调用 Matlab function 更好的方法来解决这个问题,因为对数似然 function 是凹的。

You should ask your question in the statistical website , or have a look at my former question there .你应该在统计网站上问你的问题,或者看看我以前的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM