【发布时间】:2014-07-26 01:01:40
【问题描述】:
我试图弄清楚以下代码 sn-p 中 @(t) 的用途是什么:
[theta] = ...
fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)), ...
initial_theta, options);
lrCostFunction:
function [J, grad] = lrCostFunction(theta, X, y, lambda)
%LRCOSTFUNCTION Compute cost and gradient for logistic regression with
%regularization
% J = LRCOSTFUNCTION(theta, X, y, lambda) computes the cost of using
% theta as the parameter for regularized logistic regression and the
% gradient of the cost w.r.t. to the parameters.
和选项:
options = optimset('GradObj', 'on', 'MaxIter', 50);
我会很感激一些解释。提前致谢
【问题讨论】:
-
这是一个匿名函数。单变量 theta 在 lrCostFunction 中进行了优化。 mathworks.com/help/matlab/matlab_prog/anonymous-functions.html
标签: matlab