# 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

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

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

Dot operator

### do not print result of statement / REDUCE VERBOSE OUTPUT

Append “;” to statement

## 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.