Part 7: Cognitive Analogies - Brain-inspired Learning

Category: Deep Learning

Part 7: Cognitive Analogies — Brain-inspired Learning

Parts 1–6 covered the mechanics: neurons, training, tensors, data loading, parameters, and backpropagation. You now have a complete picture of how the spam-detection model works from a mathematical and engineering perspective.

Part 7 takes a step back. Before diving into specialised architectures like CNNs in Part 9, it is useful to ask: why do these mechanics work at all? The answer lies in how closely deep learning mirrors the way biological brains learn — not perfectly, but closely enough to be instructive.

Neural networks are called “neural” because they borrow ideas from the brain. But they are not brains. In this guide, we use the spam-detection example to see how deep learning mirrors ideas from human cognition.


1. The brain as a pattern machine

Your brain is great at recognising patterns:

  • You can spot a friend’s face in a crowd.
  • You can understand a sentence you have never heard before.
  • You can tell when an email looks suspicious.

A spam filter does the same kind of thing. It learns patterns from many examples and then recognises those patterns in new emails.

Memory trick: A neural network is like a student. Show it many spam and normal emails, let it make mistakes, and it slowly improves.


2. Neurons and synapses

In the brain:

  • Neurons receive signals, process them, and send signals onward.
  • Synapses are the connections between neurons. Stronger synapses mean stronger influence.

In our spam model:

  • Artificial neurons receive weighted email features, add a bias, and apply an activation.
  • Weights are the artificial synapses. Learning means strengthening or weakening these weights.

For example, if “unknown sender” is a strong spam signal, the weight from that feature to the spam neuron becomes large. If “known sender” is a strong normal signal, the weight from that feature becomes negative.

Brain:         Dendrite -> Soma -> Axon -> Synapse
Neural Net:    Input -> Weighted Sum -> Activation -> Output

Memory trick: Weights are the brain’s synapses. Training is the brain practising.


3. Learning by repetition

When you practise a skill, your brain strengthens the connections that lead to good outcomes and weakens the ones that lead to mistakes.

A spam-filtering neural network does the same thing during training:

  1. Forward pass — predict whether each email is spam
  2. Compute loss — measure the mistake
  3. Backward pass — find which weights caused the mistake
  4. Update weights — strengthen good paths, weaken bad paths

This is the brain’s “trial and error” turned into maths.


4. Hebbian learning — neurons that fire together, wire together

There is a famous rule in neuroscience:

“Cells that fire together, wire together.”

It means that if two neurons are active at the same time, the connection between them becomes stronger.

In our spam model, this is similar to the idea that weights update together when they both contributed to the same prediction. If “many links” and “unknown sender” both activate for spam emails, the network learns to strengthen both connections.

Memory trick: “Fire together, wire together” = “train together, strengthen together”.


5. Memory and weights

You can think of a trained spam filter as a kind of memory.

  • The network’s weights store everything it learned from the training emails.
  • When you show it a new email, the weights help it recognise what the email is similar to.

This is not exact memory like a hard drive. It is distributed memory — the knowledge is spread across all the weights, not stored in one place.

Memory trick: Weights are like a blurry photograph. The whole picture is in the pixels, but no single pixel is the picture.


6. Layered processing in the brain

Your brain processes information in layers:

  • Retina — captures light
  • Visual cortex — detects edges and shapes
  • Higher cortex — recognises faces, objects, and scenes

A deep spam filter does something similar:

  • Input layer — raw email features or word tokens
  • Early hidden layers — detect simple patterns like “many links” or “all capitals”
  • Deeper hidden layers — detect combinations like “many links + unknown sender”
  • Output layer — spam probability

This is why deep networks work well for text, images, and audio.


7. Attention — focus on what matters

Your brain does not process everything equally. When you read an email, you focus on the important parts.

“Congratulations! Click here to claim your prize.”

Your attention is drawn to words like “Congratulations”, “claim”, and “prize”. Attention mechanisms in deep learning do the same. They let the model decide which parts of the input to focus on.

For example, when classifying an email, the model might pay more attention to suspicious words and less attention to common words like “the” or “and”.

Memory trick: Attention is like a spotlight. It highlights the important parts of the email.


8. Generalisation — learning the idea, not the example

A good student does not memorise every question. They learn the underlying idea so they can answer new questions.

A good spam filter does the same. It should perform well on emails it has never seen. This is called generalisation.

If a spam filter memorises the training emails instead of learning the pattern, it is overfitting.

  Memorisation Generalisation
Training emails Perfect Good
New emails Fails Good
Analogy Cramming for a test Understanding the subject

9. Learning from mistakes — the loss function

Your brain has a kind of internal feedback loop:

  • Expected outcome versus actual outcome
  • If they differ, adjust future behaviour

In neural networks, the loss function measures the difference between the predicted spam probability and the true label. The network then uses gradients to reduce that loss.

Brain Neural Network
Surprise or error signal Loss value
Adjust behaviour Update weights via gradient descent
Repeat practice Repeat epochs

For spam detection, a common loss is binary cross-entropy. It punishes confident wrong predictions more than uncertain ones.


10. Plasticity and fine-tuning

The brain can change its connections throughout life — this is called neuroplasticity.

In deep learning, we have a similar idea called fine-tuning:

  • A pretrained model already knows general patterns.
  • We show it new data, and only a small part of the network changes.
  • This is much faster than training from scratch.

For spam detection, you might start with a model trained on general text and then fine-tune it on your specific email data.

Memory trick: Pretraining = learning a language. Fine-tuning = learning to write poetry in that language.


11. Receptive fields — what each neuron sees

In your visual cortex, each neuron only responds to a small part of what you see. This small area is called its receptive field.

In convolutional neural networks, each neuron also looks at only a small patch of the input. This is why CNNs are so good at vision. For spam detection, an early neuron might look at just one word or a small window of features.


12. Hierarchical feature learning for spam

Here is how features become more complex as you go deeper in a spam filter:

Layer Vision Network Spam Network
Input Pixels Words or hand features
Layer 1 Edges, colours Word patterns like “free” or “prize”
Layer 2 Shapes, textures Phrases like “claim your prize”
Layer 3 Eyes, wheels, fur Combinations like “unknown sender + many links”
Layer 4 Faces, cars, animals Full spam intent

Memory trick: Deep networks build understanding like a pyramid — simple bricks at the bottom, complex ideas at the top.


13. What neural networks are NOT

It is important to avoid over-interpreting the brain analogy.

Brain Neural Network
Uses real neurons and chemicals Uses numbers and matrix multiplication
Learns continuously Trains in batches
Has emotions, goals, and reasoning Has none of these
Understands causality Finds correlations in data
Uses very little energy Needs GPUs and lots of power

A neural network is inspired by the brain, but it is a mathematical tool — not a mind.


14. A spam-filter brain analogy

Imagine your brain learning to detect spam:

  1. At first, you might just check if the email says “WIN” or “FREE”.
  2. After seeing more examples, you notice that unknown senders are also suspicious.
  3. Eventually, you learn subtle combinations: “short email + many links + unknown sender” is a strong spam signal.

A deep neural network goes through the same progression. Early layers learn simple checks. Deep layers learn subtle combinations. The loss function is like a teacher correcting the network after each batch.


15. Quick review

Brain Idea Deep Learning Equivalent Spam Example
Neurons Artificial neurons / units Nodes that process email features
Synapses Weights How strongly a feature connects to spam
Firing together, wiring together Weight updates through backpropagation Suspicious features strengthen together
Memory Distributed weights Learned spam detection behaviour
Receptive fields Small windows in early layers One word or one feature window
Hierarchical processing Deep layers learning features Simple checks to complex combinations
Attention Attention mechanisms Focus on suspicious words
Plasticity Fine-tuning and transfer learning Adapting a pretrained model to your emails
Learning from mistakes Loss function and gradient descent Binary cross-entropy updates weights
Generalisation Performance on unseen emails Correctly classifying new spam

16. Try it yourself

Think about these questions in your own words:

  1. When you learn to recognise spam, which “features” do you notice first? How is that like the first layer of a neural network?
  2. Why is overfitting like memorising answers instead of understanding a subject?
  3. How does a spam filter’s attention to suspicious words relate to your own attention when reading an email?
  4. What is the difference between the brain’s plasticity and fine-tuning a neural network?

Summary

  • Neural networks are inspired by the brain but are not brains.
  • Weights are like synapses; training is like strengthening useful connections.
  • Deep layers learn features in a hierarchy, just like the visual cortex.
  • Attention lets the model focus on relevant parts of the input.
  • Generalisation is the goal: the model should perform well on new emails.
  • Fine-tuning is like neuroplasticity — adapting a pretrained model to a new task.
  • The brain analogy is helpful, but remember that deep networks are mathematical pattern recognisers.
  • For spam detection, the network learns to recognise patterns that humans also notice, but it stores that knowledge as numerical weights, not readable rules.

A neural network showing how simple inputs build into complex decisions through layers