A neural network is a supervised machine learning technique that can be used for classification or regression problems. We will focus here on classification problems only.
We will describe here a very basic artificial neural network (ANN), only composed of an input neuron and an output neuron. This is network will not be able to predict anything useful but it’s a good way to understand the general concepts behind ANNs.
This ANN maps an input x (there is only one feature here) to a predicted output . We define a weight and a bias between the 2 layers. The role of the ANN is to adjust the weight and the bias.
is the output of an activation function such as the Sigmoid function. This function squashes a real number into the [0, 1] interval. If the real number is negative, the output is close to 0 and if it is positive, the output is close to 1.
We can write the predicted output as follows,
In order to adjust the weight and bias, we need to define a cost function . In this case, we will use the Mean Square Error (MSE) but we could use other ones.
Where is the number of observations, is the label of each observation and is the label predicted by our network.
In order to minimise the mean square error (i.e. the cost function ), we will use the method of the Gradient Descent applied to the weight.
Where is the learning rate. We will use the chain rule of differentiation to calculate the gradient.
Using previous equations, we can calculate each of the terms.
We can do the same for the bias.
That’s it! If we iterate the process enough times, the cost function will decrease and the weight and bias will converge to their optimal values.
In the next article, we will add a hidden layer between between the input and output layer to illustrate how the weights and biases are adjusted using Backpropagation.