Yes we can!

What we have today is a form of AI that is trained to solve a particular problem. (Let’s save Chat-GPT et al until later.) We’ll focus on machine learning using neural networks.

We start with a set of data about a particular problem. It could be handwritten characters we want to recognise, or a set of data about house prices we want to predict. The important thing here is that the data is classified. In other words, we already know what the characters are or what the house prices are. We are going to use that data to train our AI.

Each neuron in our neural network is a simple piece of logic which takes any number of inputs. It weights each one and sums the result. Then it uses a threshold function to decide what the output should be.

We arrange the neurons in layers. We have an input layer, then several hidden layers, and an output layer. Each neuron in one layer takes input from all the neurons in the layer above it. The output from a neuron is thus fed to each neuron in the layer beneath it.

The weights attached to each neuron input are given random values to start with. So the results we get will be similarly random. So how to make it smart? The answer is to compute the error between what we wanted and what the output was, and feed that error back up the links in the neural network (backpropagation) adjusting the weights to minimize the error.

Test on enough data and keep iterating and the errors will go down. Eventually, if the data makes sense in the first place and your neural network will start to predict with some level of accuracy.

I’ve simplified a lot here, there are all sorts of ways of tweaking things to improve accuracy and speed of training but let’s skip that and jump into how you build one. Not a line by line explanation, if you can code, you’ll find that there are lots of walk throughs out there. What I’m trying to achieve is an explanation of what’s involved to prove the point that it is not hard and does not require specialist equipment and can be done for free.

The easiest environment to write your neural network is in Google Colab. It is an online coding environment that supports GPU acceleration (which you’ll need to get things done in a reasonable amount of time).

TensorFlow is an open-source library that allows you to create neural networks with just a few lines of code, literally. Import the library, add an input layer, add some hidden layers, then an output layer. Define some parameters, import some data and you’re done.

Yes, there will be more to do, but my point here is that it is not a mysterious black art. Anyone who can program could create one in a few minutes. That is important because as we move through this series of posts the opportunity for thinking AIs are magic will return.