Completed:
Coursera Week 3 Lectures
Coursera EX2
Coursera Week 4 Section 1
EX 1 Companion
TODO:
Coursera EX3
Lessons Learned:
fminunc
fminunc finds a local minimum of a function of several variables.
X = fminunc(FUN,X0) starts at X0 and attempts to find a local minimizer
X of the function FUN. FUN accepts input X and returns a scalar
function value F evaluated at X. X0 can be a scalar, vector or matrix.
X = fminunc(FUN,X0,OPTIONS) minimizes with the default optimization
parameters replaced by values in OPTIONS, an argument created with the
OPTIMOPTIONS function. Use the SpecifyObjectiveGradient option to specify
that FUN also returns a second output argument G that is the partial derivatives of the
function df/dX, at the point X. Use the HessianFcn option to specify
that FUN also returns a third output argument H that is the 2nd partial
derivatives of the function (the Hessian) at the point X. The Hessian
is only used by the trust-region algorithm.
OPTIONS = optimoptions(SOLVER,'PARAM1',VALUE1,...) creates default
optimization options for SOLVER with the named parameters altered with
specified values. OPTIONS can also be created using optimoptions
and setting the parameters via dot notation. For example:
% Create and set parameters using optimoptions
options = optimoptions('fminunc','StepTolerance',0.01,'Display','iter')
% Give matrix X with dimension m x n
1 2 3
4 5 6
7 8 9
% add a column of ones in front of X: X = [ones(m,1) X]
1 1 2 3
1 4 5 6
1 7 8 9
% add a row of zeros on top X = [zeros(1, n) ; X]
0 0 0 0
1 2 3 1
4 5 6 1
7 8 9 1
% T(:,1) returns 1st column of T
1
4
7
% T(:,1) returns 1st row of T
1 2 3
% initial theta is a vector of 0's
% log(X) is an element wise operation
% 1 - X is an element wise operation
0 -1 -2
-3 -4 -5
-6 -7 -8
%