File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ function [pred ] = softmaxPredict(softmaxModel , data )
2+
3+ % softmaxModel - model trained using softmaxTrain
4+ % data - the N x M input matrix, where each column data(:, i) corresponds to
5+ % a single test set
6+ %
7+ % Your code should produce the prediction matrix
8+ % pred, where pred(i) is argmax_c P(y(c) | x(i)).
9+
10+ % Unroll the parameters from theta
11+ theta = softmaxModel .optTheta ; % this provides a numClasses x inputSize matrix
12+ pred = zeros(1 , size(data , 2 ));
13+
14+ %% ---------- YOUR CODE HERE --------------------------------------
15+ % Instructions: Compute pred using theta assuming that the labels start
16+ % from 1.
17+
18+
19+
20+ size(pred ) % 1 10000
21+ size(data ) % 784 10000
22+ size(theta )% 10 8
23+
24+ p = theta * data ;
25+ [junk , idx ] = max(p , [], 1 );
26+
27+ pred = idx
28+
29+ % ---------------------------------------------------------------------
30+
31+ end
32+
You can’t perform that action at this time.
0 commit comments