Skip to content

Module 01

Anurag Prasad edited this page Nov 7, 2026 · 10 revisions

Module 01: Linear Algebra, Vector Spaces and Tensor Mathematics

Curriculum part: Mathematical and Theoretical Foundations
Study level: Foundational
Content status: Substantive introductory chapter; supporting exercises and implementations are maintained separately.

1. Why this module matters

Deep learning computations are linear-algebra operations over batches. Dense layers are matrix products; convolutions, attention and graph aggregation are structured tensor operations.

2. Learning objectives

After studying this module, you should be able to:

  • Explain the central problem and assumptions of the methods covered.
  • Interpret the principal mathematical objects, equations and tensor dimensions.
  • Work through a small numerical example without relying on a framework.
  • Implement or verify the central operation using NumPy or PyTorch.
  • Identify failure modes and select appropriate follow-up material.

3. Prerequisites and connections

Prerequisites: School algebra, functions and coordinate geometry.

The module follows the principle write once, reference everywhere. Foundational derivations are maintained in their primary module; later modules focus on how those ideas are used rather than repeating the full derivation.

4. Core concepts and theory

Scalars, vectors, matrices and higher-order tensors differ by the number and meaning of their axes. A batch of tabular data is commonly B×d; an image batch may be B×C×H×W; token representations may be B×T×d. Always name axes: shape alone does not tell whether an axis is batch, channel, time or feature. Vector spaces support addition and scalar multiplication. Dot products measure alignment; norms measure magnitude; hyperplanes define linear decision boundaries. Matrix multiplication composes linear maps and requires matching inner dimensions. Rank describes the dimension of a matrix's column space. Eigenvectors describe invariant directions; SVD decomposes any real matrix into orthogonal directions and singular values. Tensor contraction generalizes dot products.

5. Mathematical formulation

A compact form of the central operation is:

$$ Y = XW + b $$

Y=XW+b, with X∈R^(B×d_in), W∈R^(d_in×d_out), b∈R^d_out and Y∈R^(B×d_out). ||x||₂=√(Σxᵢ²); cos(x,y)=xᵀy/(||x||₂||y||₂); A=UΣVᵀ.

The equations above define the main computational objects. When implementing them, specify tensor shapes, reduction axes, normalization conventions and whether a loss is summed or averaged. Those details determine the actual computation.

6. Worked numerical reasoning

Let x=(2,−1,3) and w=(1,2,−1). Their dot product is −3, so they are not orthogonal. Their norms are √14 and √6; cosine similarity is −3/√84≈−0.327. A 32×128 batch multiplied by a 128×64 weight matrix produces a 32×64 output.

Use the example as a check on notation and implementation. Change one input at a time and verify how the output changes; this is often more informative than immediately moving to a large dataset.

7. Computational workflow

flowchart TD
    A[Define the problem and data] --> B[Identify mathematical objects]
    B --> C[Write equations and tensor shapes]
    C --> D[Work through a small numerical case]
    D --> E[Implement the operation]
    E --> F[Verify outputs and gradients]
    F --> G[Evaluate limitations and connect to later modules]
Loading

8. Implementation and verification

Implement dot products, norms, matrix multiplication and SVD reconstruction in NumPy. Trace all shapes through a two-layer MLP. In PyTorch, note that nn.Linear(in,out) stores weights as (out,in), even though the mathematical row-batch expression is XW.

A good implementation sequence is:

  1. Write the operation in plain mathematical notation.
  2. Calculate a tiny example by hand.
  3. Implement the operation with NumPy.
  4. Compare against a trusted PyTorch operation.
  5. Add shape and numerical assertions.
  6. Only then run a larger experiment.

See the implementation roadmap for a module-specific progression.

9. Common misconceptions and failure modes

Do not confuse tensor order with semantic meaning, tensor order with matrix rank, or matrix multiplication with elementwise multiplication. Broadcasting can silently produce a valid but unintended shape. Convolution and attention have their own layout conventions.

10. Advanced directions

Study conditioning, low-rank approximation, sparse matrices, orthogonal parameterizations, tensor decompositions and numerical precision. These recur in embeddings, LoRA, attention and scientific ML.

These are extensions beyond the minimum conceptual foundation. Treat them as directions for further reading or experiments, not as claims that an implementation or benchmark is already complete.

11. Focused pages and practice

This module is best studied as one integrated chapter; the lesson map divides the reading sequence without duplicating the theory.

12. Where this concept is used

13. Scope and content provenance

The original course material is the primary basis for the course topics in this curriculum. Mathematical prerequisites are included to make the course topics understandable from first principles. Additional modern methods are identified as extensions where appropriate. The chapter does not imply that every proposed coding exercise or research experiment has already been executed.

15. Selected references

These sources provide canonical starting points for the concepts in this chapter. They are not a claim that every extension listed above is covered by the original course material.

  • Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press.
  • Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press. Chapter 2.

16. Completion criteria

  • Explain the main ideas in your own words.
  • Re-derive the central equations and check dimensions.
  • Solve the worked example independently.
  • Complete at least one numerical exercise.
  • Implement and verify the central operation.
  • Explain at least two limitations or failure modes.
  • Follow the cross-module links relevant to your learning path.

Next: Continue to the lesson map or return to the curriculum map.

🎓 Deep Learning Hub

🏠 Home · 🗺️ Curriculum · 🧭 Learning paths

❓ Question bank · 📖 Glossary · 📚 References

Jump to module:

01 02 03 04 05 06 07 08 09 10 11 12

13 14 15 16 17 18 19 20 21 22 23 24

Part 1 · Mathematical foundations
Part 2 · Neural network fundamentals
Part 3 · Training deep networks
Part 4 · Core architectures
Part 5 · Representation and generative learning
Part 6 · Specialised, modern and responsible deep learning
Reference and meta

Clone this wiki locally