Foundations Of Deep Learning
The Deep Learning Landscape & Tooling
Chapter 2 showed a neuron implemented directly in NumPy. Real deep learning systems have millions or billions of weights, organized across dozens of layers, tra
Jr Codex Deep Learning Notes
Level: Beginner Prerequisites: Chapter 3: A Brief History of Deep Learning Time to complete: ~20 minutes
Table of Contents
- Why Frameworks Exist
- The Major Frameworks
- Why This Curriculum Uses PyTorch
- Tensors — The Core Data Structure
- GPUs and Why They Matter
- Setting Up Your Environment
- The Broader Ecosystem
- Summary & Next Steps
1. Why Frameworks Exist
Chapter 2 showed a neuron implemented directly in NumPy. Real deep learning systems have millions or billions of weights, organized across dozens of layers, trained on GPUs, requiring automatic gradient computation (Module 2, Chapter 4) across an enormous computational graph. Hand-writing this at scale is impractical — deep learning frameworks exist to handle it.
What a Deep Learning Framework Provides
─────────────────────────────────────────
1. Automatic differentiation: computes gradients (Module 2,
Ch.4) automatically, however
complex the network
2. GPU acceleration: runs the same code on a CPU
or GPU with minimal changes
3. Pre-built layers: convolutions, attention,
LSTMs — no need to
re-derive the math for
common architecture
pieces
4. Optimizers: Adam, SGD, RMSProp
(Module 3) implemented
and tested
─────────────────────────────────────────
2. The Major Frameworks
The Landscape
─────────────────────────────────────────
PyTorch: developed by Meta AI, the dominant framework in
research and increasingly in production;
"define-by-run" style feels close to writing
regular Python
TensorFlow/ developed by Google; historically dominant in
Keras: production/mobile deployment; Keras
provides a simpler, higher-level API on
top of TensorFlow
JAX: developed by Google; popular for
cutting-edge research requiring
maximum performance and flexible
automatic differentiation
─────────────────────────────────────────
3. Why This Curriculum Uses PyTorch
This curriculum uses PyTorch throughout, for practical reasons: it is currently the dominant framework in both research publications and industry deployment, its syntax closely mirrors standard NumPy (already familiar from the Python Notes and ML Notes), and virtually all modern pretrained models (Module 7, and the entire NLP & LLM Notes) are published with PyTorch-native weights via the HuggingFace ecosystem.
4. Tensors — The Core Data Structure
A tensor is PyTorch's fundamental data structure — conceptually a generalization of a NumPy array, but with two additions: it can live on a GPU, and it automatically tracks operations for gradient computation.
import torch
import numpy as np
# A tensor looks and behaves almost exactly like a NumPy array
numpy_array = np.array([[1.0, 2.0], [3.0, 4.0]])
tensor = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
print(tensor.shape) # torch.Size([2, 2]) — same concept as NumPy's .shape
print(tensor + tensor) # element-wise operations work identically
# The key DIFFERENCE — automatic gradient tracking
x = torch.tensor([2.0], requires_grad=True) # "track gradients for this tensor"
y = x ** 2
y.backward() # compute dy/dx automatically (Module 2, Ch.4's backpropagation)
print(x.grad) # tensor([4.]) — PyTorch computed this derivative for usTensor Dimensionality, by Convention
─────────────────────────────────────────
0-D (scalar): a single number — e.g. a loss value
1-D (vector): a list of numbers — e.g. one data
sample's features
2-D (matrix): a BATCH of samples, or a single
grayscale image
3-D: a batch of sequences, or a
single color image
(height, width, channels)
4-D: a BATCH of color images
— the typical shape fed
into a CNN (Module 4)
─────────────────────────────────────────
5. GPUs and Why They Matter
Chapter 1 identified GPU compute as one of the three enablers of practical deep learning. The reason: neural network training is dominated by matrix multiplications, and GPUs contain thousands of small cores that can perform many of these multiplications simultaneously, in contrast to a CPU's handful of cores optimized for sequential tasks.
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"Using device: {device}")
tensor = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
tensor = tensor.to(device) # move the tensor to the GPU (if available)
# EVERY tensor involved in an operation must be on the SAME device —
# a common, easily-fixed beginner error is mixing CPU and GPU tensors6. Setting Up Your Environment
# CPU-only (fine for this curriculum's smaller examples)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# GPU (CUDA) version — check pytorch.org for the command matching your CUDA version
pip install torch torchvision torchaudio
# Supporting libraries used throughout this curriculum
pip install numpy matplotlib scikit-learn pandas# Verify your installation
import torch
print(f"PyTorch version: {torch.__version__}")
print(f"GPU available: {torch.cuda.is_available()}")7. The Broader Ecosystem
Libraries Built ON TOP OF PyTorch, Used Later in This Curriculum
─────────────────────────────────────────
torchvision: pretrained vision models, datasets, image
transforms (Module 4, Module 7)
torchaudio: audio-specific datasets and transforms
(mentioned for completeness; not a
focus of this curriculum)
HuggingFace the dominant hub for pretrained models
Transformers: and datasets (Module 7; central to
the NLP & LLM Notes)
─────────────────────────────────────────
8. Summary & Next Steps
Key Takeaways
- Deep learning frameworks provide automatic differentiation, GPU acceleration, and pre-built layers — without them, building networks at real-world scale would be impractical.
- This curriculum uses PyTorch, the dominant framework in both research and production, whose syntax closely mirrors NumPy.
- A tensor is PyTorch's core data structure — like a NumPy array, but capable of living on a GPU and automatically tracking gradients via
requires_grad=True. - GPUs accelerate deep learning because training is dominated by matrix multiplications, which GPUs parallelize far better than CPUs.
Module 1 Complete — What's Next
You now understand what deep learning is, why it works, how the field arrived here historically, and the tools used throughout the rest of this curriculum. Module 2 moves from concepts to mechanics: building a real neural network from scratch, understanding forward propagation, and deriving backpropagation step by step.
Concept Check
- What two capabilities does a PyTorch tensor have that a plain NumPy array does not?
- Why are GPUs particularly well-suited to neural network training?
- What must be true about two tensors before you can perform an operation between them (e.g. adding them)?
Next Module
→ Module 2: Neural Networks from Scratch
Jr Codex — 1-on-1 Personalized Coaching | Back to Module Index | Back to DL Index