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/01 18:38:27
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)),
xSMo@+Daլ@kHH k%@ݸ`ؑJ ')@Bժ*iz& 3޵s/0h"= z`{v73odZ\2LFdEY}RJb U+ɪ.5FdS\QuV%d?Sl /ӰXri֏u}YFV |U,fLP~GyCi徭y4cHxE7.ӷ裤' TQŧmXͼcXe}1.h]N4"%Cl?I]8FX,cM整,&FY$)F7x)ՠqEjZxr")y+ -mxRv:A7Pʈֆu'CIхG6x3z0p:]ߡyP- /' H}7liݍ72xC?~??v;m/t✏AUGr @.HgQZV,H q ! VUҋ~

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.