Tutorial Ex3
Tutorial Ex3
Tom Mosher
MentorAssignment: Multi-class Classification and Neural Networks · 4 years ago · Edited
all_theta is a matrix, where there is a row for each of the trained thetas. In the exercise example,
there are 10 rows, of 401 elements each. You know this because that's how all_theta was
initialized in line 15 of the script template.
(note that the submit grader's test case doesn't have 401 elements or 10 rows - your function
must work for any size data set - so use the "num_labels" variable).
Each call to fmincg() returns a theta vector. Be sure you use the lambda value provided in the
function header.
The oneVsAll.m script template contains several Hints and a code example to guide your work.
The "y == c" statement creates a vector of 0's and 1's for each value of 'c' as you iterate from 1 to
num_labels. Those are the effective 'y' values that are used for training to detect each label.
Type these commands in your workspace to see how to copy a vector into a matrix:
The syntax "(2,:)" means "use all columns of the 2nd row".
Note that your function must return the predictions as a column vector - size (m x 1). If you return
a row vector, the script will not compute the accuracy correctly.
Note: When you multiply by the Theta matrices, you'll have to use transposition to get a result
that is the correct size.
Note: The predictions must be returned as a column vector - size (m x 1). If you return a row
vector, the script will not compute the accuracy correctly.
Note: Not getting the correct results? In the hidden layer, be sure you use sigmoid() first, then
add the bias unit.
a1 is (m x n), where 'n' is the number of features including the bias unit
a2 is (m x (h + 1))
a3 is (m x c)
p is a vector of size (m x 1)