因此,我正在尝试从课程中解决有关onevsAll分类的问题。它属于Andrew NG的ml课程。我无法在代码中找到错误,并且一直显示此错误
error: fmincg: operator +: nonconformant arguments (op1 is 401x1, op2 is 4x1)
error: called from
fmincg at line 87 column 5
oneVsAll at line 60 column 13
ex3 at line 77 column 13
我尝试阅读fmincg
代码,但我无法理解问题。
function [all_theta] = oneVsAll(X, y, num_labels, lambda)
% Some useful variables
m = size(X, 1);
n = size(X, 2);
% You need to return the following variables correctly
all_theta = zeros(num_labels, n + 1);
% Add ones to the X data matrix
X = [ones(m, 1) X];
for c = 1:num_labels
initial_theta = zeros(n+1,1) ;
options = optimset('GradObj', 'on', 'MaxIter', 50);
[theta] = fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)),initial_theta, options);
all_theta(c, :) = theta;
end;
程序显示上述有关fmincg
文件的错误。