Add neural network prediction function
This commit is contained in:
parent
3bf3d9fdc3
commit
073fbf0204
1 changed files with 14 additions and 5 deletions
|
@ -21,13 +21,22 @@ p = zeros(size(X, 1), 1);
|
|||
% can use max(A, [], 2) to obtain the max for each row.
|
||||
%
|
||||
|
||||
% Theta1 has size 25x401
|
||||
% Theta2 has size 10x26
|
||||
|
||||
a1 = [ones(m, 1) X];
|
||||
% a1 has size mx401
|
||||
|
||||
a2_tmp = sigmoid(a1 * Theta1');
|
||||
% a2_tmp has size m x 401 * 401 x 25 = m x 25
|
||||
a2 = [ones(m, 1) a2_tmp];
|
||||
% a2 has size m x 26
|
||||
|
||||
a3 = sigmoid(a2 * Theta2');
|
||||
% a3 has size m x 26 * 26 x 10 = m x 10
|
||||
% note: sigmoid not actually neded here (arg max(sigmoid(z)) = arg max(z))
|
||||
|
||||
|
||||
|
||||
|
||||
[~, p] = max(a3, [], 2);
|
||||
|
||||
% =========================================================================
|
||||
|
||||
|
|
Reference in a new issue