DEEP LEARNING LESSON 1 FOUNDATIONS

A Simple Deep Learning Example

Let's put the basic Deep Learning ideas together with a simple example. We will use a small student dataset and see how a neural network can learn to predict whether a student will pass an exam.

The simple idea

We give the neural network examples containing student information and the correct result. The network learns patterns from those examples and uses the learned patterns to make predictions for new students.

The Problem We Want to Solve

Suppose we want to predict whether a student will pass an exam.

We have three inputs:

Hours Studied
Attendance
Previous Score

The output is:

Pass
or
Fail

Our Training Data

We first give the neural network examples of students whose results are already known.

Hours
Attendance
Previous Score
Result
8
90%
85
Pass
7
85%
78
Pass
2
55%
45
Fail
3
60%
50
Fail

These examples are called training data. The model uses them to learn relationships between the inputs and the result.

Step 1 — Give the Data to the Neural Network

The student's information becomes the input to the neural network.

INPUT
Hours Studied
Attendance
Previous Score
HIDDEN LAYERS
Learn Patterns
Combine Information
OUTPUT
Pass / Fail

Step 2 — The Network Makes a Prediction

Suppose we give the network a new student:

6 Hours
80% Attendance
Score: 72

The network processes these values and produces a prediction.

Student Data
Neural Network
Prediction: Pass

At the beginning of training, the prediction may not be correct. That is normal.

Step 3 — Compare the Prediction With the Answer

During training, we already know the student's actual result.

Example

Model prediction: Fail

Actual result: Pass

The model made a mistake, so it needs to adjust its internal parameters.

Step 4 — Calculate the Loss

The model uses a loss function to measure how far its prediction is from the correct answer.

Prediction
+
Actual Answer
Loss

A larger error generally produces a larger loss, while a prediction closer to the target generally produces a smaller loss.

Think of loss as a mistake score

The loss tells the model how well or poorly it performed on the current training example.

Step 5 — Update the Model

The network uses the error information to adjust its weights and other parameters.

Loss
Calculate Gradients
Update Weights
Improve

This process allows the network to make better predictions the next time it sees similar examples.

Step 6 — Repeat the Process

The network does not learn from only one student. It repeats the process for many training examples.

Make Prediction
Calculate Loss
Update Weights
Next Example
Repeat

After many updates, the network can learn useful relationships between student information and exam results.

Step 7 — Predict for a New Student

After training, we can give the model information about a student it has never seen before.

7 Hours
88% Attendance
Score: 80
Trained Network
Pass

The important point is that the model is not simply memorizing the training examples. It is using the patterns it learned to make a prediction for new data.

Complete Example

Training Data
Neural Network
Prediction
Loss
Weight Update
Better Model

This cycle continues across many examples and training steps until the model has learned useful patterns from the training data.

What Did the Model Learn?

The model does not store a simple rule such as "study more than 6 hours means pass."

Instead, training changes its numerical parameters so that the network can learn relationships between the different inputs.

Hours Studied
+
Attendance
+
Previous Score
Learned Relationship

These learned relationships are then used to produce predictions for new students.

Important

This is a simplified example. Real neural networks can contain many layers, many neurons, and millions or even billions of parameters. But the basic learning cycle remains the same: predict, measure error, update, and repeat.

QUICK CHECK

Check Your Understanding

What is the input in our example?
Hours studied, attendance, and previous score.

What is the output?
Whether the student is predicted to pass or fail.

What happens when the prediction is wrong?
The model calculates the loss and uses the error information to update its parameters.

Why do we repeat the process?
Repeated updates allow the model to gradually learn useful patterns from the training data.

NEXT TOPIC

Build It With Python

Now we will take this simple idea and build a small Deep Learning model using Python.