資源簡介
softmax回歸是邏輯回歸的延伸,用來處理多分類問題,此代碼是用matlab實現

代碼片段和文件信息
function?numgrad?=?computeNumericalGradient(J?theta)
%?numgrad?=?computeNumericalGradient(J?theta)
%?theta:?a?vector?of?parameters
%?J:?a?function?that?outputs?a?real-number.?Calling?y?=?J(theta)?will?return?the
%?function?value?at?theta.?
??
%?Initialize?numgrad?with?zeros
numgrad?=?zeros(size(theta));
%%?----------?YOUR?CODE?HERE?--------------------------------------
%?Instructions:?
%?Implement?numerical?gradient?checking?and?return?the?result?in?numgrad.??
%?(See?Section?2.3?of?the?lecture?notes.)
%?You?should?write?code?so?that?numgrad(i)?is?(the?numerical?approximation?to)?the?
%?partial?derivative?of?J?with?respect?to?the?i-th?input?argument?evaluated?at?theta.??
%?I.e.?numgrad(i)?should?be?the?(approximately)?the?partial?derivative?of?J?with?
%?respect?to?theta(i).
%????????????????
%?Hint:?You?will?probably?want?to?compute?the?elements?of?numgrad?one?at?a?time.?
epsilon=0.0001;
n=size(theta1);
E=eye(n);
for?i=1:n
????delta=E(:i)*epsilon;
????numgrad(i)=(J(theta+delta)-J(theta-delta))/(epsilon*2.0);
end
%%?---------------------------------------------------------------
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1114??2014-03-26?09:27??softmax_exercise\computeNumericalGradient.m
?????文件????????811??2014-03-25?21:18??softmax_exercise\loadMNISTImages.m
?????文件????????516??2011-04-25?17:32??softmax_exercise\loadMNISTLabels.m
?????文件???????3251??2011-01-03?21:39??softmax_exercise\minFunc\ArmijoBacktrack.m
?????文件????????807??2011-01-03?21:39??softmax_exercise\minFunc\autoGrad.m
?????文件????????901??2011-01-03?21:39??softmax_exercise\minFunc\autoHess.m
?????文件????????317??2011-01-03?21:39??softmax_exercise\minFunc\autoHv.m
?????文件????????870??2011-01-03?21:39??softmax_exercise\minFunc\autoTensor.m
?????文件????????385??2011-01-03?21:39??softmax_exercise\minFunc\callOutput.m
?????文件???????1845??2011-01-03?21:39??softmax_exercise\minFunc\conjGrad.m
?????文件????????995??2011-01-03?21:39??softmax_exercise\minFunc\dampedUpdate.m
?????文件???????2421??2011-01-03?21:39??softmax_exercise\minFunc\example_minFunc.m
?????文件???????1604??2011-01-03?21:39??softmax_exercise\minFunc\example_minFunc_LR.m
?????文件????????107??2011-01-03?21:39??softmax_exercise\minFunc\isLegal.m
?????文件????????924??2011-01-03?21:39??softmax_exercise\minFunc\lbfgs.m
?????文件???????2408??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.c
?????文件???????7707??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexa64
?????文件???????7733??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexglx
?????文件???????9500??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexmac
?????文件??????12660??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexmaci
?????文件???????8800??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexmaci64
?????文件???????7168??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexw32
?????文件???????9728??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsC.mexw64
?????文件????????614??2011-01-03?21:39??softmax_exercise\minFunc\lbfgsUpdate.m
?????文件????????417??2011-01-03?21:39??softmax_exercise\minFunc\logistic\LogisticDiagPrecond.m
?????文件????????216??2011-01-03?21:39??softmax_exercise\minFunc\logistic\LogisticHv.m
?????文件????????659??2011-01-03?21:39??softmax_exercise\minFunc\logistic\LogisticLoss.m
?????文件???????1154??2011-01-03?21:39??softmax_exercise\minFunc\logistic\mexutil.c
?????文件????????317??2011-01-03?21:39??softmax_exercise\minFunc\logistic\mexutil.h
?????文件????????227??2011-01-03?21:39??softmax_exercise\minFunc\logistic\mylogsumexp.m
............此處省略33個文件信息
- 上一篇:Matlab5.3精簡版免安裝壓縮包
- 下一篇:H.264源碼for MATLAB
評論
共有 條評論