Table of Contents
Prologue
The Search for Intelligent Machines
For thousands of years, we humans have tried to understand how our own intelligence works and replicate it in some kind of machine - thinking machines.
Weve not been satisfied by mechanical or electronic machines helping us with simple tasks - flint sparking fires, pulleys lifting heavy rocks, and calculators doing arithmetic.
Instead, we want to automate more challenging and complex tasks like grouping similar photos, recognising diseased cells from healthy ones, and even putting up a decent game of chess. These tasks seem to require human intelligence, or at least a more mysterious deeper capability of the human mind not found in simple machines like calculators.
Machines with this human-like intelligence is such a seductive and powerful idea that our culture is full of fantasies, and fears, about it - the immensely capable but ultimately menacing HAL 9000 in Stanley Kubricks 2001: A Space Odyssey , the crazed action Terminator robots and the talking KITT car with a cool personality from the classic Knight Rider TV series.
When Gary Kasparov, the reigning world chess champion and grandmaster, was beaten by the IBM Deep Blue computer in 1977 we feared the potential of machine intelligen ce just as much as we celebrated that historic achievement.
So strong is our desire for intelligent machines that some have fallen for the temptation to cheat. The infamous mechanical Turk chess machine was merely a hidden person inside a cabinet!
A Nature Inspired New Golden Age
Optimism and ambition for artificial intelligence were flying high when the subject was formalised in the 1950s. Initial successes saw computers playing simple games and proving theorems. Some were convinced machines with human level intelligence would appear within a decade or so.
But artificial intelligence proved hard, and progress stalled. The 1970s saw a devastating academic challenge to the ambitions for artificial intelligence, followed by funding cuts and a loss of interest.
It seemed machines of cold hard logic, of absolute 1s and 0s, would never be able to achieve the nuanced organic, sometimes fuzzy, thought processes of biological brains.
After a period of not much progress an incredibly powerful idea emerged to lift the search for machine intelligence out of its rut. Why not try to build artificial brains by copying how real biological brains worked? Real brains with neurons instead of logic gates, softer more organic reasoning instead of the cold hard, black and white, absolutist traditional algorithms.
Scientist were inspired by the apparent simplicity of a bee or pigeon's brain compared to the complex tasks they could do. Brains a fraction of a gram seemed able to do things like steer flight and adapt to wind, identify food and predators, and quickly decide whether to fight or escape. Surely computers, now with massive cheap resources, could mimic and improve on these brains? A bee has around 950,000 neurons - could todays computers with gigabytes and terabytes of resources outperform bees?
But with traditional approaches to solving problems - these computers with massive storage and superfast processors couldnt achieve what the relatively miniscule brains in birds and bees could do.
Neural networks emerged from this drive for biologically inspired intelligent computing - and went on to become one of the most powerful and useful methods in the field of artificial intelligence. Today, Googles Deepmind, which achieves fantastic things like learning to play video games by itself, and for the first time beating a world master at the incredibly rich game of Go, have neural networks at their foundation. Neural networks are already at the heart of everyday technology - like automatic car number plate recognition and decoding handwritten postcodes on your handwritten letters.
This guide is about neural networks, understanding how they work, and making your own neural network that can be trained to recognise human handwritten characters, a task that is very difficult with traditional approaches to computing .
Introduction
Who is this book for?
This book is for anyone who wants to understand what neural network are. Its for anyone who wants to make and use their own. And its for anyone who wants to appreciate the fairly easy but exciting mathematical ideas that are at the core of how they work.
This guide is not aimed at experts in mathematics or computer science. You wont need any special knowledge or mathematical ability beyond school maths.
If you can add, multiply, subtract and divide then you can make your own neural network. The most difficult thing well use is gradient calculus - but even that concept will be explained so that as many readers as possible can understand it.
Interested readers or students may wish to use this guide to go on further exciting excursions into artificial intelligence. Once youve grasped the basics of neural networks, you can apply the core ideas to many varied problems.
Teachers can use this guide as a particularly gentle explanation of neural networks and their implementation to enthuse and excite students making their very own learning artificial intelligence with only a few lines of programming language code. The code has been tested to with a Raspberry Pi, a small inexpensive computer very popular in schools and with young students.
I wish a guide like this had existed when I was a teenager struggling to work out how these powerful yet mysterious neural networks worked. I'd seen them in books, films and magazines, but at that time I could only find difficult academic texts aimed at people already expert in mathematics and its jargon.
All I wanted was for someone to explain it to me in a way that a moderately curious school student could understand. Thats what this guide wants to do.
What will we do?
In this book well take a journey to making a neural network that can recognise human handwritten numbers.
Well start with very simple predicting neurons, and gradually improve on them as we hit their limits. Along the way, well take short stops to learn about the few mathematical concepts that are needed to understand how neural networks learn and predict solutions to problems.
Well journey through mathematical ideas like functions, simple linear classifiers, iterative refinement, matrix multiplication, gradient calculus, optimisation through gradient descent and even geometric rotations. But all of these will be explained in a really gentle clear way, and will assume absolutely no previous knowledge or expertise beyond simple school mathematics.
Once weve successfully made our first neural network, well take idea and run with it in different directions. For example, well use image processing to improve our machine learning without resorting to additional training data. Well even peek inside the mind of a neural network to see if it reveals anything insightful - something not many guides show you how to do!
Well also learn Python, an easy, useful and popular programming language, as we make our own neural network in gradual steps. Again, no previous programming experience will be assumed or needed.
How will we do it?
The primary aim of this guide is to open up the concepts behind neural networks to as many people as possible. This means well always start an idea somewhere really comfortable and familiar. Well then take small easy steps, building up from that safe place to get to where we have just enough understanding to appreciate something really cool or exciting about the neural networks.