Completed:
Coursera Week 4 Lectures
Review Coursera weeks 1-4 material
EX3
Coursera Week 5 section 1
TODO:
Coursera Week 5
EX4
Lessons Learned:
% Randomly select 100 data points to display
% let X be a 3 x 3 matrix
1 2 3
4 5 6
7 8 9
% size ()
[M,N] = size(X) for matrix X, returns the number of rows and columns in
X as separate output variables.
[M, N] = 3 3
M = size(X,DIM) returns the lengths of the specified dimensions in a
row vector. DIM can be a scalar or vector of dimensions. For example,
size(X,1) returns the number of rows of X and size(X,[1 2]) returns a
row vector containing the number of rows and columns.
randperm Random permutation.
P = randperm(N) returns a vector containing a random permutation of the
integers 1:N. For example, randperm(6) might be [2 4 5 6 1 3].
%"unroll" matrices into vector
%[matrix1(:); matrix2(:); matrix3(:); ] --> combine three matrices into one long vector
thetaVector = [ Theta1(:); Theta2(:); Theta3(:); ]
Theta1 = reshape(thetaVector(1:110),10,11) --> columns 1:110 turned into 10 X11 Theta2 = reshape(thetaVector(111:220),10,11) Theta3 = reshape(thetaVector(221:231),1,11)
input to fminunc is the unrolled vector
use matrices for forward and backward propagation
Use unrolled vector for calculation of D
% let X be a 3 x 3 matrix
1 2 3
4 5 6
7 8 9
reshape Reshape array.
reshape(X,M,N) or reshape(X,[M,N]) returns the M-by-N matrix
whose elements are taken columnwise from X. An error results
if X does not have M*N elements.
Minimize a continuous differentialble multivariate function. Starting point
is given by "X" (D by 1), and the function named in the string "f", must
return a function value and a vector of partial derivatives.
EX 3
% X <-- 5000 x 400
rand_indices = randperm(m);
% returns a row vector of 5000 elements ranging from 0 - 5000
% Randomly select 100 data points to display
sel = X(rand_indices(1:100), :);
displayData(sel);
m = size(X, 1);
% m = 5000; X has 5000 rows