Computer generated image of a single neuron

Introduction

Welcome to part 2 of my “Understanding neural networks” series. In Part 1 – The artificial neuron, I introduced the core component of the biological brain, the neuron, and described its artificial counterpart. I touched on briefly on how complex behaviour can arise from such a simple component and explained a simple example. In part 2 I’ll dig a bit deeper into how neurons are arranged in the brain and in artificial neural networks (ANNs).

Getting deep with hidden layers

Studies of the structure of the brain suggest that the neurons within it are grouped into layers, with each layer connected to the next in a “forward” sequence. Inputs from sensory organs such as the eyes, ears, and nerves in the skin enter at the first layer and outputs from the final layer connect to other areas of the brain and to the muscles in the body via the spinal cord.

Creators of ANNs attempt to duplicate this by also arranging their artificial neurons in separate layers. When there are a lot of layers, we tend to refer to these as deep networks, which gives rise to the term “deep learning”. All layers apart from the input and output layer are referred to as “hidden layers” because they are not visible to the outside world. In reality they are far from hidden as their inputs and outputs can be easily accessed.

Both the terms “deep” and “hidden” give these networks an air of mystery that is not, in my opinion, justified. Deep just means “lots” and hidden just means “not an output”.

In the simplest of these networks, all inputs connect to the first layer, the first layer connects forward to the second layer and so on until the final output layer. Because all connections feed forward, it won’t come as a surprise to find out this layout is known as a “feed forward network”.

Most feed forward networks are also “fully connected”. This just means that each input is connected to every neuron in the first layer, and each neuron in a layer is connected to every neuron in the next layer.

Figure 1: A fully-connected feed-forward network

Positive feedback is a gift

It’s great to receive positive feedback, and in neural networks the same is true for negative feedback. In biological brains the neurons within a layer are connected to one another, and also back to neurons in previous layers. These connections feed information from later layers back to earlier neurons, and are therefore referred to as feedback connections.

This style of connectivity is also used in ANNs, and these networks are known as “recurrent networks”. Allowing connections to happen in all directions significantly increases the complexity of the resulting ANN. These networks are rarely “fully connected” and usually feedback connections within a layer are more numerous than feedback connections between different layers. 

The presence of feedback connections in brains raises an important question for the world of AI. If feedforward networks work well for many situations, what does feedback add? Is it functionally important or just a quirk of biology?

Context matters

Not surprisingly, it turns out to be very important. Most situations that require a decision to be made are highly dependent not just on the current situation, but what came before. This is the “prior context”. For example, choosing which of two doors to open would appear to be a 50/50 choice without prior context. However, if moments before you had heard a loud, deep growl from behind one of those doors that 50/50 would change dramatically.

What feedback provides is effectively an echo of what came before. The input on which the brain acts is a combination of what it is receiving right now through its sensory organs, and a fading echo of the events leading up to that moment. It’s important to note that this is not the same thing as memory. Memory is long term and represents a long term change within the brain.

Much is made of the question of whether AIs are “aware” in the way that humans are. This can be a complex question, but for networks with no feedback it is, in my opinion, a very firm no, not ever. Without feedback there can be no awareness, as the moment input stops, so does brain activity. With feedback, brain activity is self-sustaining.

A second advantage provided by feedback is when it is negative. Biological brains are incredibly efficient. They are good at using just enough neurons to perform a task and no more, leaving the rest free to solve other problems. They achieve this using negative feedback. Essentially, if a neuron fires strongly in a particular situation, any neurons to which it provides negative feedback are encouraged not to fire. This enables a process known as “competitive learning” which helps animals understand and categorise the world around them.

There’s another really important advantage to feedback that only becomes apparent when you look at what is going on inside a recurrent neural network. In my early work with this type of layout, I was using it to develop an image recognition solution. One of the big issues in image recognition is the “occlusion problem”.

Out of sight, out of mind

Figure 2: Raccoon behind a tree

Animals (humans included) are great at recognising objects. More importantly they’re great at recognising bits of objects.

AI is not so good, especially in the second of these cases. When we see just a bit of a Raccoon, peeking out from behind a tree, we instantly know it’s a raccoon. Simple obstructions like this can fool an AI. Even a fancy coloured shirt can convince an AI you aren’t actually a person.

One explanation for this is that animals see thousands of examples of an object during their early development. Machines are rarely presented with such a rich and varied set of experiences. However, even when training sets are significantly expanded, the problem remains. Meanwhile, children recognise objects after only a few examples, even when they’re partially hidden.

One thing I discovered, early in my experiments with recurrent networks, was something I call “input reinforcement”. I was training a network to recognise simple images of black shapes on a white background, and I was interested to see what was going on inside. I’m a very visual person so I created a graphic that plotted the outputs of the artificial neurons as squares arranged on a grid. Each square represented one neuron and the size of the square represented the size of the output. I will refer to this as “lighting up”.

This produced a great picture of the network in action and it was fascinating to see the neurons “light up” when familiar images were presented at the inputs. So, when a square was presented, I saw a square at the inputs, and a “random” pattern of internal neurons specific to the square. (Different patterns were seen for each different shape).

Once seen, never forgotten

What was particularly interesting, however, was the sequence of events that happened when just part of an image was presented. When presented with a square that had one corner cut off, the sequence went like this:

  1. The input neurons lit up to match the partial image (white dots were represented by a zero input and black dots as ones).
  2. The hidden neurons lit up in a pattern similar to the pattern for the square, but with a few differences.
  3. Over a short period of time, some of the hidden neurons turned off and others turned on until a stable pattern was achieved.
  4. The final pattern was the one for the full square.

What did this mean? It meant that the learning process had created feedback connections that ensured that neurons that had fired together during previous learning, were caused to fire when enough of the inputs matched one of the trained shapes. The network wasn’t just recognising the square full square – it was effectively “remembering” the missing part of the square and “seeing” the whole square.

I’m putting “remembering” and “seeing” in quotation marks here to avoid attributing human attributes to the network, but they are reasonable analogies for what I observed. My conclusion was that the presence of feedback connections was a key feature that allowed networks to learn quickly based on limited training sets. It also potentially gives some insight into how optical illusions work. Our brains are naturally designed to fill in the hidden detail, even when it isn’t there.

Figure 3: One long cow, or two cows behind a pillar?

The double edged sword

Essentially, any problem that can only be solved with knowledge of prior context that isn’t in the inputs requires a recurrent network. So, if recurrent networks are more capable, why would you ever go back to the limitations of feed-forward networks? The answer is that with additional capability, come problems. 

Firstly, feedback can be a tricky thing to manage. If you’ve ever heard that painful screeching sound that microphones make, right in the middle of someone’s important speech, you’ll have experienced what happens when positive feedback gets out of control. All those echoes add up, and if you’re not careful they take over and you just get noise. 

Secondly, all those extra connections take up processing time. The more connections you have, the more computing power you need to perform all the calculations. If you want to solve tricky problems you’re going to need lots of neurons, and even more connections. Recurrent networks generally need more connections than feed forward networks do for the same number of neurons.

Finally, it turns out that recurrent networks can be much harder to teach than feed-forward networks. This brings us neatly to the question of training, which will be covered in part 3.