Journal · Jun 03, 2026

Build ML Model with Pen and Paper

Build ML Model with Pen and Paper

Build ML Model with Pen and Paper

A gentle introduction to ML and the underlying math — from matrix multiplication to the essence of deep learning.

A gentle introduction to ML and the underlying math — from matrix multiplication to the essence of deep learning.

Overview

Overview

Overview

A deep learning model takes data as input and outputs a prediction: identifying the mushroom in a picture, picking the next word in a sentence, or estimating a house’s price. It all comes down to three critical pieces:

A deep learning model takes data as input and outputs a prediction: identifying the mushroom in a picture, picking the next word in a sentence, or estimating a house’s price. It all comes down to three critical pieces:

  • Input – your data (say, an image), converted into a matrix

  • Weights – another matrix that gets multiplied with the input to form a prediction

  • Loss function – how far that prediction lands from the truth

  • Input – your data (say, an image), converted into a matrix

  • Weights – another matrix that gets multiplied with the input to form a prediction

  • Loss function – how far that prediction lands from the truth

It sounds complex, but it’s mostly matrix multiplication with a little calculus mixed in.

It sounds complex, but it’s mostly matrix multiplication with a little calculus mixed in.

Linear Algebra & Calculus Review

Linear Algebra & Calculus Review

Linear Algebra & Calculus Review

The part of linear algebra relevant to deep learning is matrix operations.

The part of linear algebra relevant to deep learning is matrix operations.

NOTE: GPUs became a critical part of deep learning because they pack thousands of small cores that run arithmetic in parallel – exactly what matrix multiplication needs.

NOTE: GPUs became a critical part of deep learning because they pack thousands of small cores that run arithmetic in parallel – exactly what matrix multiplication needs.

Even though modern tools such as PyTorch and TensorFlow are relatively forgiving for engineers without a strong math background, it’s still worth reviewing the basics to build intuition.

Even though modern tools such as PyTorch and TensorFlow are relatively forgiving for engineers without a strong math background, it’s still worth reviewing the basics to build intuition.

Matrix Multiplication

Matrix Multiplication

Matrix Multiplication

The building block is the dot product of two vectors. The result is the sum of element-wise products between a horizontal row vector and a vertical column vector.

The building block is the dot product of two vectors. The result is the sum of element-wise products between a horizontal row vector and a vertical column vector.

[1 2 3] · [4 5 6] = 1·4 + 2·5 + 3·6 = 32

[1 2 3] · [4 5 6] = 1·4 + 2·5 + 3·6 = 32

Note what happened to the shape: two vectors of length 3 collapse into one scalar, a single number. The vectors must be the same length, since every element needs a partner.

Note what happened to the shape: two vectors of length 3 collapse into one scalar, a single number. The vectors must be the same length, since every element needs a partner.

Matrix multiplication is just this dot product done many times. Each entry in the result is the dot product of a row from the left and a column from the right.

Matrix multiplication is just this dot product done many times. Each entry in the result is the dot product of a row from the left and a column from the right.

Derivatives

Derivatives

Derivatives

© 2026 Random Moth. All rights reserved.

© 2026 Random Moth. All rights reserved.

© 2026 Random Moth. All rights reserved.