Classify your Doodles with Code

Neural networks and machine learning


Table of Contents

  1. Classify your Doodles using coding with Javascript
  2. The P5 coding environment
  3. Neural networks and machine learning
  4. Coding
  5. Challenges
  6. Reference

Neural Networks

Neural Networks (or more correctly, Artificial Neural Networks) have been created by computer scientists to solve certain types of tricky problems in computing. They do this by creating a network of simple computing units that in some ways work in a similar way to how the human brain works.

The brain is made up of of neurons, that look something like this:

Neuron

A signal can be transmitted from one end to the other. Neurons "fire" under certain conditions, e.g. when you sense something or decide to do something.

Lots of neurons are connected together in the brain:

Brain

When one neuron fires, it can trigger other neurons to fire. This complex inter-connection of the neurons allows us humans to perform some amazing tasks!


What amazing human tasks can you think of? What is the path from sensing to decision to action that our brain makes to achieve these tasks?


In computing, we can create an artificial neuron as a small bit of code that performs a simple calculation, taking some inputs (e.g. a, b and c) and producing an output (e.g. y):

A neuron

The circle represents a function. A simple function could be:

y = a + b + c

But to get our neuron to solve real problems we need it to perform a slightly more complicated function (but it's not that much more complicated). It looks something like this:

A neuron 2
y = t + a x w1 + b x w2 + c x w3

Don't worry about the maths - we won't be needing this to do the activity!


If we combine lots of these simple calculating units we create something called an artificial neural network (ANN):

Ann

We can train these ANNs to recognise certain patterns. We can then present different inputs to the ANN and they will classify them according to how the ANN was trained:

Ann dog Ann cat

Image Classification

The ability to classify images is very useful! We can use it to help search for images (think of Google image search) or to recognise road signs (which is what self-driving cars need to do).

Road signs

Similar technology can be used to recognise things like people on the street, as shown in this video about driverless cars:



Can you think of other uses for image classification?


Machine Learning

The process of training a neural network to recognise different images is called machine learning.

First we take lots of different examples of images that we want to recognise and run them through the neural network: Train1

The neural networks adjusts itself so that all the little calculations are tuned to the images that it sees. This is represented by the changing colours in the picture below: Train2

We can then present different images to the neural network, which runs all the calculations and determines what the image is: Train3Train4

What do you think would happen if we presented a picture of a mouse to the above neural network?


Table of Contents

  1. Classify your Doodles using coding with Javascript
  2. The P5 coding environment
  3. Neural networks and machine learning
  4. Coding
  5. Challenges
  6. Reference