AI Fundamentals Course (AI101) โ€“ Lesson7

๐ŸŽ“ Lesson 7: Neural Networks and How They Work


Lesson Objective:

To help learners understand what Artificial Neural Networks (ANNs) are, how they are inspired by the human brain, and how they function to enable modern AI systems.

โ†’ This is an important chapter of this course. Please study carefully.


What Are Neural Networks?

While their full name is Artificial Neural Networks (ANNs), they are commonly referred to as “Neural Networks”, or sometimes “Neural Nets”

A Neural Network is a type of machine learning model that is inspired by the structure and function of the human brain.

Just like our brains have neurons connected by synapses, a neural network consists of digital โ€œneuronsโ€ arranged in layers โ€” and they learn by passing signals between them.

Neural Networks allow machines to learn from complex data like images, sound, and language. They are the core of many AI systems.


The Inspiration: The Human Brain

Your brain contains about 86 billion neurons.
Each neuron receives signals, processes them, and sends outputs to other neurons.

A neural network simulates this process digitally, with layers of artificial neurons that:

  • Receive input (data)

  • Process it using weighted connections

  • Pass results to the next layer

  • Output a prediction or decision


Basic Structure of a Neural Network

  1. Input Layer โ€“ Receives the data (e.g., pixels in an image or words in a sentence)

  2. Hidden Layers โ€“ Perform calculations and learn patterns

  3. Output Layer โ€“ Produces the final answer or prediction

Example:
For a photo of a cat, the output layer might say:
โ†’ 95% Cat, 4% Dog, 1% Other


Big Question: How Does a Neural Network Learn?

  1. Data is passed through the network.

  2. Each connection between neurons has a weight (importance level).

  3. The system compares its prediction with the correct answer (label).

  4. It adjusts the weights to improve accuracy โ€” a process called backpropagation.

  5. This cycle is repeated thousands or millions of times until the network becomes very good at the task.

Think of it as a “trial and error” based learningโ€” but at lightning speed!


Real-Life Example: Image Recognition

Letโ€™s say we want to build an AI (using Neural Networks) to recognize cats in photos.

  • We show it thousands of labeled images (cat or not-cat).

  • The neural network starts learning what a โ€œcatโ€ looks like: eyes, ear shape, whiskers, fur texture, etc. All of these biological features have similar patterns in cats, and neural network learns these patterns (at a pixel level on the images).

  • Eventually, after seeing thousands of cats, it can look at a new image itโ€™s never seen before and say: โ€œThatโ€™s a cat!โ€

Important Note on AI Evolution: The above AI system (Neural Networks in this case) would be learning about the cat by learning about the image patterns at pixel level. If an adversarial system (enemy) manages to corrupt a just few pixels (~ 0.01%) across the image in a precise way, then the AI system may not be able to see the cat anymore, even though the human eye can clearly see the cat. This action of corrupting the data of an AI system at a micro level is called “Data Poisoning” — and to prevent such threats/actions — will be a major work for Cybersecurity systems in the future. The AI systems have to evolve from today’s micro level learning to wholistic learning, where they are able to see the big picture along with micro level details. Then even after some image pixels are corrupted, the AI will still see the cat, like a human. AI is not there yet, but will reach there in the coming years.


Analogy: Layers of Understanding

Imagine a human learning to recognize a dog:

  • First, we see the shape (ears, tail)

  • Then, we remember past experiences

  • Then, we distinguish it from a wolf or a fox

  • Finally, we say โ€œThatโ€™s a dog!โ€

Neural networks go through layers of analysis, just like we do โ€” from raw data to meaning.


Real Life Example of Backpropagation in Neural Networks

Letโ€™s consider a simple example to illustrate the steps of backpropagation in a neural network.

Example: Predicting House Prices
Suppose we have a neural network that predicts house prices based on the number of bedrooms and square footage. Our network has two input neurons (bedrooms and square footage), two hidden neurons, and one output neuron (predicted price).

Step 1: Forward Pass
Letโ€™s say we input a house with 3 bedrooms and 2000 sqft into our network. The network processes this information and predicts a price of $400,000. However, the actual price of the house is $450,000.

Step 2: Error Calculation
We calculate the error between the predicted price and the actual price: $450,000 โ€“ $400,000 = $50,000. This error value represents how far off our prediction was from the actual price.

Step 3: Backward Pass
We propagate the error value backwards through the network, adjusting the weights and biases of the connections between neurons. This process helps us identify which neurons and connections contributed most to the error.

Step 4: Weight Update
Based on the error value and the gradients of the loss function, we update the weights and biases of the network. For example, we might adjust the weight of the connection between the โ€œbedroomsโ€ input neuron and the first hidden neuron to better reflect the relationship between bedrooms and house prices.

How Backpropagation Improves the Network
Through backpropagation, our network learns to adjust its weights and biases to minimize the error between predicted and actual prices. Over time, the network becomes more accurate in its predictions, and we can use it to make informed decisions about house prices.

Real-Life Analogy
Think of backpropagation like a marksman adjusting their aim after missing a target.ย The marksman (network) takes a shot (makes a prediction), sees where it lands (calculates the error), and adjusts their aim (updates the weights and biases) to hit the target more accurately in the future. With each iteration, the marksman becomes more accurate, just like our neural network becomes more accurate with each round of backpropagation.


Business Use Cases of Neural Networks

Industry AI Use Case
Healthcare Detecting tumors in medical scans
Finance Identifying fraudulent transactions
Retail Recommending products based on behavior
Entertainment Personalizing content on Netflix or Spotify
Transportation Powering self-driving car vision systems

Recommended Reading to learn more about Backpropagation in Neural Networks:

Backpropagation in Neural Networks

Fun Fact: The neural network behind ChatGPT (the most popular AI program currently) is called a Transformer, which is a special kind of deep neural network designed to understand human language and reply in human language. It has billions of artificial neurons!

Recommended Reading to learn more about Transformers:

Transformers for Deep Learning AI


Reflection Prompt (for Learners)

  • Have you ever used an app or tool (like Google Photos or facial recognition) that may have used a neural network behind the scenes?


โœ… Quick Quiz (not scored)

  1. What is a neural network inspired by?

  2. What are the three main parts of a neural network?

  3. What is backpropagation?

  4. Give one real-world use case for neural networks.

  5. True or False: Neural networks are only used for images.


Key Takeaway

Neural Networks are the brain behind modern AI.
They allow machines to learn patterns, make predictions, and adapt to complex data โ€” just like how our brains learn from experience.