for label=1:num_labels\x09y_binary = y == label;\x09initial_theta = zeros(n + 1,1);%%401*1的零矩阵\x09options = optimset('GradObj','on','MaxIter',50);%%MaxIter是允许迭代的次数\x09[theta] = fmincg(@(t)(lrCostFunction(t,X,y_binary,lambda)),
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 22:34:03
for label=1:num_labels\x09y_binary = y == label;\x09initial_theta = zeros(n + 1,1);%%401*1的零矩阵\x09options = optimset('GradObj','on','MaxIter',50);%%MaxIter是允许迭代的次数\x09[theta] = fmincg(@(t)(lrCostFunction(t,X,y_binary,lambda)),
for label=1:num_labels
\x09y_binary = y == label;
\x09initial_theta = zeros(n + 1,1);%%401*1的零矩阵
\x09options = optimset('GradObj','on','MaxIter',50);%%MaxIter是允许迭代的次数
\x09[theta] = fmincg(@(t)(lrCostFunction(t,X,y_binary,lambda)),initial_theta,options);
\x09all_theta(label,:) = theta;
end
%%num_labels=10,y是5000*1的矩阵,X是5000*400的矩阵,lambda=0.1;
不明白的是第二行,矩阵能和数判断相等吗?还有第五航的t是什么意思?
for label=1:num_labels\x09y_binary = y == label;\x09initial_theta = zeros(n + 1,1);%%401*1的零矩阵\x09options = optimset('GradObj','on','MaxIter',50);%%MaxIter是允许迭代的次数\x09[theta] = fmincg(@(t)(lrCostFunction(t,X,y_binary,lambda)),
矩阵==数,则生成的结果为一个和原矩阵相同大小的二值逻辑矩阵,如果矩阵某一元素==那个数,则逻辑阵对应位置为1,否则为0.