Deep Learning

Deep Learning — From Scratch

Deep Learning for Beginners | Part 1 — What Is Deep Learning?
Deep Learning Guide · Part 1 of 3

Deep Learning — From Zero

A comprehensive English guide for beginners with no prior background. In this part we cover what deep learning is, how it differs from machine learning, how neural networks “think,” and what makes them “deep” — with detailed examples and diagrams.

✍ Abdurrahman Al-Rifai
Beginners
Deep + examples
01 Definition

What is deep learning?

Deep learning (DL) is a specialized branch of machine learning (ML) built on artificial neural networks with many stacked layers. Each layer learns increasingly abstract representations from raw data.

When you talk to ChatGPT, unlock your phone with Face ID, or use Google Translate — deep learning is usually running behind the scenes. It is not magic; it is math + massive data + powerful computers (GPUs).

In plain words

Imagine teaching a child to tell a cat from a dog. At first they notice simple details (color, size). Over time they build deeper concepts: ear shape, gait, fur texture. A deep neural network works the same way: layer after layer extracts patterns from simple to complex — edges → shapes → parts → whole object.

The core idea: automatic feature learning

In traditional ML, an expert often hand-picks “features”: tail length, eye color, nose shape. In deep learning, the network discovers features on its own from data. You do not need to tell it “look for ears”; it will find them if they help the task.

That is why DL excels with:

  • Images: millions of pixels — hard to engineer features manually.
  • Text: word meaning shifts with context.
  • Audio: complex waves that resist simple rules.
02 Relationship

Artificial intelligence → machine learning → deep learning

Three nested concepts — like concentric circles. Understanding where DL sits clarifies the big picture.

Artificial Intelligence (AI) Any system that mimics intelligence: rules, search, ML, DL Machine Learning (ML) Learning from data without explicit rules for every case Deep Learning (DL) Multi-layer neural networks All DL is ML; most modern ML is AI — but not vice versa
The hierarchy: AI ⊃ ML ⊃ DL

Artificial intelligence

The broad umbrella: any technology that makes machines “smart” — chess rules, expert systems, ML, DL.

Machine learning

A way to achieve AI: the model learns from examples. Includes trees, SVM, random forests, and neural nets.

Deep learning

ML using deep neural networks (typically 3+ hidden layers). Strongest on images, text, and audio.

Illustrative example

Spam filtering: solve with classic AI (rules: “if subject contains FREE”). Or ML (Naive Bayes on thousands of emails). Or DL (LSTM that reads full context). All are AI — but DL wins when text is complex and data is abundant.

03 Depth

Why “deep”? What do layers mean?

Deep means the network has multiple hidden layers — not just one or two neurons. Each layer transforms inputs into a slightly richer representation.

Analogy: a factory assembly line

  1. Layer 1: inspect raw materials — “this is metal, this is plastic.”
  2. Layer 2: combine parts — “engine block, frame.”
  3. Layer 3: assembly — “car chassis.”
  4. Layer 4: finishing — “red BMW 2024.”

For images, a deep network might learn:

  • Layer 1: edges, lines, color gradients.
  • Layer 2: simple shapes (circles, triangles).
  • Layer 3: parts (eye, ear, wheel).
  • Layer 4: whole objects (face, car, cat).
How many layers = “deep”?

No magic number. Traditionally 3+ hidden layers counts as deep. Today GPT-class models may have dozens or hundreds of layers (via Transformer blocks). More depth (with enough data) can capture richer patterns — but training gets harder.

04 History

History of deep learning — from winter to revolution

The “artificial neuron” idea is old — but modern success needed three factors: big data, GPUs, and better algorithms.

YearMilestoneWhy it matters
1943McCulloch & Pitts — first neuron modelMathematical foundation: neuron = function + threshold
1958Perceptron — RosenblattFirst trainable network — then criticized
1969–2006“AI winter”Deep nets hard to train; limited compute
2006Hinton — pre-trainingRenewed interest in deep networks
2012AlexNet — ImageNetCNN wins by ~10%+ — DL returns in force
2016AlphaGo beats Go championDL + reinforcement learning milestone
2017Transformer paperFoundation of GPT and modern LLMs
2022–2026ChatGPT, GPT-4, multimodal modelsDL in everyday tools — productivity revolution
Why 2012 was a turning point

ImageNet: classify 1.2M images into 1000 categories. AlexNet (deep net + GPU) hit 15.3% error — second place 26%. The gap was huge. Industry realized: data + GPU + deep nets = the future of AI.

05 Building block

The artificial neuron

A neuron (node/unit) is a small calculator: take inputs, multiply each by a weight, sum, add bias, pass through an activation function.

Analogy: a purchase decision

You decide whether to buy a phone using price (×0.4), camera (×0.3), battery (×0.2), brand (×0.1). Sum: 0.4×7 + 0.3×9 + 0.2×8 + 0.1×6 = 7.7. If > 7 → buy. A neuron does the same mathematically — but weights are learned from data, not set by you.

output = activation( w₁×x₁ + w₂×x₂ + ... + wₙ×xₙ + bias )
  • Inputs (x): data — pixels, numbers, features.
  • Weights (w): importance of each input — learned during training.
  • Bias (b): shifts the decision threshold.
  • Activation: nonlinear transform — covered below.
06 Perceptron

Perceptron — the simplest neural network

The Perceptron (1958) is a single neuron — the simplest trainable model. It classifies points into two classes with a linear boundary.

Practical example: student admission

Two inputs: GPA (0–4) and study hours/week (0–40). Goal: “admitted” or “rejected.”

After thousands of labeled examples, weights might be w₁=0.6, w₂=0.3, b=-2.5. Student with GPA=3.5, study=25: 0.6×3.5 + 0.3×25 + (-2.5) = 7.1 → activation → “admitted.”

Limits of a single perceptron

One perceptron only separates data linearly. XOR cannot be solved with one neuron. The fix: multiple layers — a Multi-Layer Perceptron (MLP).

07 Architecture

Network layers — input, hidden, output

Input layer

Receives raw data. A 28×28 image = 784 neurons. Does not “learn” — just passes values through.

Hidden layers

Where “depth” lives. Each layer transforms the previous representation. Real learning happens here.

Output layer

Final prediction. 10 classes = 10 neurons (probability each). Regression = 1 neuron.

In a fully connected layer, every neuron connects to every neuron in the next layer. Layer 784 → 128 → 10 ≈ 101,000 weights — all learned.

08 Forward pass

Forward propagation

When you feed data into a trained network, it flows layer by layer (input → hidden → output). Each layer computes outputs from the previous layer.

Step-by-step: MNIST digit classification

Input: 28×28 = 784 grayscale pixels.

Step 1: 784 values → hidden layer (128 neurons). Each: y = ReLU(w·x + b).

Step 2: 128 → second hidden (64 neurons).

Step 3: 64 → output (10 neurons for digits 0–9).

Result: Softmax → [0.01, 0.02, 0.85, ...] → prediction: digit 2 (85%).

Note: Forward pass runs in both training and inference. During training, we then compute error and run backpropagation (Part 2).

09 Activation

Activation functions

Without nonlinear activations, any number of layers collapses to a single straight line — useless. Activations add “curvature” so networks learn complex patterns.

FunctionIdeaWhen to use
ReLUmax(0, x) — zero if negativeDefault for hidden layers — fast, helps vanishing gradient
SigmoidSquashes to 0–1 (probability)Binary output, older architectures
Softmaxn numbers → n probabilities summing to 1Multi-class output layer
TanhLike sigmoid but -1 to +1RNNs, some hidden layers
Leaky ReLUSmall slope when negativeWhen standard ReLU “dies”
Softmax example

Output logits for cat, dog, bird: [2.0, 1.0, 0.1]. Softmax → [0.659, 0.242, 0.099] — “cat” at 65.9%. Highest wins.

10 Usage

When should you use deep learning?

✓ Use DL when: lots of data (thousands–millions), complex patterns (images, text, audio), high accuracy needed, GPU available.
✗ Skip DL when: tiny data (<1000), simple tables, need clear explainability, limited resources — XGBoost or Random Forest may suffice.
  • Machine translation: Google Translate — Transformer.
  • Face recognition: Face ID — CNN.
  • Voice assistants: Siri, Alexa — speech + NLP.
  • Self-driving cars: CNN + LiDAR fusion.
  • Image generation: DALL-E, Midjourney — diffusion/GAN.
  • ChatGPT: Transformer LLM.
11 Glossary

Essential terms

TermPlain meaning
Neural networkNetwork of interconnected neurons
Deep network3+ hidden layers
Weight / biasNumbers the model learns
Forward propagationData flow input → output
Loss functionMeasures prediction error — Part 2
EpochOne full pass over training data
GPUHardware that speeds DL training 10–100×
TensorMulti-dimensional array — DL data unit
Next step

You understand what the network is and how data flows. In Part 2 we cover how it learns: backpropagation, gradient descent, CNN, RNN, and practical training.

FAQ Questions

Common questions about DL fundamentals

Do I need advanced math for this part?
No for conceptual understanding — analogies and examples are enough. For building models you will gradually need linear algebra, calculus, and probability. But the basics are accessible without them.
What is the difference between ML and DL?
DL is ML with deep neural networks. ML is broader — trees, SVM, etc. DL shines on images, text, and audio; classic ML may suffice for small tabular data.
How many layers for my first project?
Start with 2–3 hidden layers. MNIST: 2 often enough. CIFAR: 3–5. Do not start with 50 layers — overfitting and training pain await.
Is DL just ChatGPT?
No. ChatGPT is one type (LLM). DL also powers image classification, object detection, translation, speech, games (AlphaGo), medical diagnosis, and more.