您的位置:首页 > 其它

UFLDL Exercise:Softmax Regression

2015-06-25 19:41 375 查看

1. result

Gradient checking: 7.4115e-010

Accuracy: 92.640%

2. code

softmaxCost

%hypothesis
M = theta * data;
M = exp(bsxfun(@minus, M, max(M)));
M = bsxfun(@rdivide, M, sum(M));
%cost
cost = -sum(sum(groundTruth .* log(M))) / size(data, 2);
cost = cost + 0.5 * lambda * sum(sum(theta .* theta));
%grad
thetagrad = -(groundTruth - M) * data' / size(data, 2)';
thetagrad = thetagrad + lambda * theta;


softmaxPredict

M = theta * data;
[M, pred] = max(M);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  softmax UFLDL