Neural networks and various other models of how the brain works have been around since people started talking about artificial intelligence. This article introduces you to the concept of neural networks and how to implement them using Python.
Understanding Neural Networks
Here are the six attributes of a neural network:
- A Neural Network has input layers
- It has hidden layers
- It has an output layer
- It has a set of weights and biases in every level of neurons
- A has activation function for every hidden layer of neurons.
- A loss function that provides “overtraining” of the neural network.
The figure above shows the architecture of a two-layer neural network. Note the three layers in this “two-layer” neural network: the input layer is generally excluded when you count the layers of a neural network. Looking at this diagram you can see that neurons in each layer are connected to all neurons in the next layer. Weights are given for each of the inter-neural connection lines.
The neuron, as the word is used in artificial intelligence, is a software model that has been inspired by the cell in the nervous system that behaves more or less like an actual brain neuron. The model uses numbers to make one neuron or another more important for the results. These numbers are called weights.
Layers of Neural Networks
The image above shows the input layer, hidden layer, and output layer. It’s a very simple network; real networks can be much more complex with several additional layers. Deep learning gets its name from the fact that you have several hidden layers, in a sense increasing the “depth” of the neural network.
Note that the layers filter and process information from left to right in a gradual fashion. This is called early entry because data is only transmitted in one direction.
So now that we know a neural network, how does it learn? The neural network receives an example and guesses the answer. If the answer is wrong, it goes back and changes the weights and biases in the neurons and tries to correct the error by changing some values. It’s called backpropagation and it simulates what people do when performing a task using an iterative trial and error approach.
After doing this process several times, the neural network begins to improve (learn) and provide better responses. Each of these iterations is called an epoch. This name works quite well because sometimes it takes days or weeks to provide training to learn complex tasks.
An important point to emphasize at this point is that while it may take days or weeks to train a neural network after training, we can duplicate it with little effort by copying the topology, weights and biases of the network formed. When you have a trained neural network, you can easily use it over and over again, until you need something different. Then it’s back to training.
Neural networks, as such, model certain types of human learning. However, humans have much more complex methods of hierarchically categorizing objects with little effort. Neural networks are not very good at transferring knowledge and results from one type of situation to another without retraining.
Weights and Biases
Looking at the network in the image above, you can see that the output of these neural networks only depends on the weights of the interconnection and also what we call the biases of the neurons themselves. Although the weights affect the slope of the activation function curve, the bias will shift the entire curve to the right or left. The choices of weights and biases determine the strength of the predictions of individual neurons. Neural network training involves using the input data to refine weights and biases.
The Activation Function
An activation function is an important topic to discuss when building our first neural network. It is a key part of our neural model. This is the software function that determines whether the information is passing through or being stopped by the individual neuron. However, you aren’t just using it as a gate, you are using it as a function that transforms the input signal to the neuron in a useful way.
The loss function is the last piece of the puzzle to explain. The loss function compares the result of the neural network to the desired results. Another way to think about it is that the loss function tells us how good our current results are.
I hope you liked this article on what are Neural Networks and how does it work. Feel free to ask you valuable questions in the comments section below. You can also follow me on Medium to learn every topic of Machine Learning.