What are neural networks?

Neural Networks are the foundations of much of what we call Artificial Intelligence or Machine Learning. Basically they are a type of algorithm that tries to learn patterns from data. The key word here is learn. Just like you and me we need some form of input data, for us it is from our five senses. 

Our brains then process that information and try to learn from it. So if you watch a baby trying to learn how to crawl it does it through throwing its arms and legs in different directions and the the result is fed back. Bit by bit the baby learns which sequence of movements create the best progress. 

The black box

A neural network is trying to mimic the brain and the human learning experience. You push in the data as inputs and give it the corresponding outputs. The network (model) makes a wild guess at the answer from the data and compares it to the true answer (output). The model then alters (tweaks) parameters inside the algorithm and has another go to see how much closer it got to the real answer. 

The process is repeated over and over again until it can match the input data with the corresponding output result. What happens inside the neural network is often not known. People who build large neural networks have no real idea how it does what it does. Hence people call it a black box.

But not like the brain

So what is inside the black box. What you have is a series of nodes or neurons. The simplest neural network is called a perceptron which actually means it isn’t really a neural network it is just one bit of it. Even so it can do some machine learning stuff even something as simple as a single neuron (perceptron). 

Below is a diagram of a neural network of what look like nodes connected together in layers layers. There are three layers, input, hidden and output. They are only connected from one layer to the next not within a layer. This is a fully connected neural network. You can have as many inputs and outputs as you want but it has to match the data and the task.

More art than science

In the above example there are three inputs, they could be something like temperature, humidity and atmospheric pressure. The output is whether it rains or not. You would feed in the data and compare the guess with the reality of what actually happened. The middle layer of hidden nodes is really what makes this a neural network which is where all the magic happens. Here we have one hidden layer with three nodes (neurons). 

You can have as many layers as you want and have as many modes as you want except that it then can take a very long time to compute everything and can be unnecessary. There are very few rules about how many hidden layers and nodes. You don’t even have to have the same number of nodes in each layer. This is why it can be more art than a science. 

Conclusion

It may surprise you that it is relatively easy to build a neural network, train it and use it. Getting it to work well and accurately is a whole other game entirely. It takes practise and experience and a degree of luck. However, it is only as good as the data it gets.

Image by Shubham Dhage on Unsplash

This is an excellent video showing you in more detail how a neural network works