Lesson 3 Β· Foundations

What is Deep Learning?

Deep Learning is a type of machine learning that uses neural networks with multiple layers to learn increasingly useful patterns from data.

The simple idea: Instead of manually deciding which features matter, a deep neural network can learn useful representations step by step β€” from simple patterns to more complex ones.

First: where does Deep Learning fit?

Deep Learning is not a separate world from AI and Machine Learning. It is one part of the larger AI field, and it is a powerful approach within machine learning.

Artificial Intelligence The broad field of building systems that perform tasks associated with intelligence.
Machine Learning A way for systems to learn patterns from data and examples.
Deep Learning Machine learning based on neural networks with multiple layers.

Why do we need Deep Learning?

Traditional machine learning can work extremely well when we can describe the important signals in a useful way. But some problems involve raw, high-dimensional data such as images, audio, and natural language.

For these problems, deciding all the useful features by hand can be difficult. Deep learning can learn representations directly from the data, which is one reason it became so important for modern computer vision, speech, and language systems.

EXAMPLE 1 Β· IMAGE RECOGNITION

From pixels to an object

Imagine an image of a dog. A deep network can learn lower-level patterns such as edges, then combine them into shapes, textures, and eventually higher-level patterns that help distinguish a dog from other objects.

Pixels→Edges→Shapes→Patterns→Dog
EXAMPLE 2 Β· SPEECH

From sound to words

A speech system receives an audio signal rather than a ready-made sentence. Neural networks can learn representations of the sound and use those patterns to recognize phonetic and linguistic structure.

What is a neural network?

A neural network is a mathematical model made from connected units often called neurons. The network takes inputs, transforms them through layers, and produces an output.

Input
x₁ xβ‚‚ x₃
β†’
Hidden layers
● ● ● ●
β†’
Output
Prediction

What does each layer do?

  • Input layer: receives the data, such as pixel values or numeric features.
  • Hidden layers: transform the information and learn intermediate representations.
  • Output layer: produces the final prediction, such as a class or probability.

Why is it called β€œdeep” learning?

The word deep refers to the use of multiple computational layers. A network with more layers can build a hierarchy of representations, where later layers can combine patterns learned by earlier layers.

Think of it as a hierarchy: a simple signal can be transformed into a more useful pattern, then that pattern can be combined with other patterns until the network can make a useful prediction.

How does a neural network learn?

A neural network starts with parameters called weights. During training, it makes predictions, compares those predictions with the correct answers, calculates how wrong it was, and adjusts its weights to reduce that error.

1. InputGive the network an example
β†’
2. PredictionNetwork produces an output
β†’
3. LossMeasure the prediction error
β†’
4. UpdateAdjust weights

This loop is repeated across many examples. Over time, the network can learn parameters that produce better predictions on data it has not seen before.

Build a small Deep Learning model in Python

Now let’s move from the idea to a real neural network. We will use TensorFlow and Keras to train a small image classifier on the MNIST handwritten-digit dataset. Each image is a 28 Γ— 28 grayscale picture, and the model learns to predict which digit from 0 to 9 it contains.

Python
import tensorflow as tf

# Load handwritten digit images
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()

# Scale pixel values from 0-255 to 0-1
x_train = x_train.astype("float32") / 255
x_test = x_test.astype("float32") / 255

model = tf.keras.Sequential([
    tf.keras.layers.Flatten(input_shape=(28, 28)),
    tf.keras.layers.Dense(128, activation="relu"),
    tf.keras.layers.Dense(10, activation="softmax")
])

model.compile(
    optimizer="adam",
    loss="sparse_categorical_crossentropy",
    metrics=["accuracy"]
)

model.fit(x_train, y_train, epochs=3, validation_split=0.1)

test_loss, test_accuracy = model.evaluate(x_test, y_test, verbose=0)
print("Test accuracy:", round(test_accuracy, 3))
OUTPUT Test accuracy: a value close to 1.0 after training

The important part is not memorizing the code. Notice the learning process: the model receives many labeled examples, calculates a loss, updates its weights, and repeats this process over several training epochs.

Read the model from the inside out

  1. Flatten: converts each 28 Γ— 28 image into a one-dimensional sequence of values.
  2. Dense(128): provides a hidden layer with 128 learned units and a ReLU activation.
  3. Dense(10): produces ten output probabilities, one for each digit from 0 to 9.
  4. Adam + loss: guides the training process so the weights can be updated toward better predictions.
PRACTICE Β· UNDERSTAND

Change the network

Change 128 hidden units to 64. Train the model again and compare the test accuracy. Then try 256. The goal is to observe that changing the network changes how much capacity it has to learn.

Open a Python notebook in Google Colab β†—

What makes Deep Learning different from simpler ML?

TRADITIONAL ML

Feature engineering is often important

Developers may transform raw data into features that help the algorithm learn. For example, a model might receive carefully selected measurements rather than raw images.

DEEP LEARNING

Representation learning is central

Neural networks can learn useful intermediate representations as part of the training process, especially for complex unstructured data.

Where is Deep Learning used?

Computer VisionImage classification, object detection, medical imaging.
SpeechSpeech recognition, transcription, voice interfaces.
LanguageTranslation, summarization, question answering, language models.
Generative AIModern generative systems are built on large neural networks.

One important limitation

Deep learning is powerful, but it is not automatically the best choice for every problem. Neural networks can require substantial data, compute, tuning, and careful evaluation. For a small structured dataset, a simpler machine learning model can sometimes be easier, faster, and more appropriate.

PRACTICE Β· CHALLENGE

Think like a deep learning engineer

Choose one problem β€” image classification, speech recognition, or text classification. Write down:

  1. What is the input?
  2. What should the model predict?
  3. What examples would you use for training?
  4. What could go wrong if the training data is poor?
Quick check: Why is deep learning called β€œdeep”?

Recap

  • Deep Learning is a branch of machine learning based on neural networks with multiple layers.
  • Layers can learn increasingly useful representations from data.
  • Training repeatedly compares predictions with correct answers and updates model weights.
  • Deep learning is especially useful for complex data such as images, audio, and language.
  • Deep learning is powerful, but simpler ML methods can still be the right choice for some problems.
Next: In the next lesson, we will move from learning patterns to Generative AI β€” systems that can create new text, images, code, audio, and other content.