In the forums of the Coursera course “Machine Learning” by Andrew Ng, there are many questions regarding the dimensions of the input matrix and theta.
Here is an intuitive guide to understanding the dimensions. Click the link below!
The dimensions of your input matrix (X) is typically clear and driven from your data.
[ # of examples, # of input variables ]
The dimensions of theta are driven from your input variables. In linear regression and binary classification, the number of outputs per example is typically 1:
[ # of input variables, # of outputs per example ]