Octave cheat sheet for Coursera Machine Learning course

Switching from / to Octave when working with the Coursera machine learning course can be a bit of a hassle, since some of the Octave syntax is special. Here is my own cheat sheet to remember the most important statements required for the exercises.

Matrices

  • , Column separator
  • ; Row separator

Submatrices

  • indexes start with one
  • slices just like in python : a(1,2:3) selects first row, cols 2 and 3

Adding ONES

Adds a column of ones on the left side

  • rows gets number of rows in X
  • ones(rows(X),1) creates a column vector of 1
  • […] combines both

TranspOSE

APPLY Operator ON VECTOR ELEMENTS

Dot operator

do not print result of statement / REDUCE VERBOSE OUTPUT

Append “;” to statement

FOR-LOOP

 

Functions

Neural Networks

Multiplication of layers

Assume calculation of layer with n nodes to m nodes, then \(\Theta \) will be a matrix with m rows and n colums. And the multiplication will be \(a^{(n+1)}=\Theta*a^{(n)}\). The final value will be \(a^{(n+1)}=sigmoid(\Theta*a^{(n)})\)

Sigmoid

which means:

\(1/{1+e^{-z}}\) for each of the vector elements.

 

Leave a Reply

Your email address will not be published. Required fields are marked *