No history yet

Mathematical Pillars

The Language of Data

To an AI model, data isn't just a list of numbers. It's a structured object called a tensor. You can think of tensors as a generalisation of concepts you're already familiar with. A single number, or scalar, is a 0-dimensional tensor. A list of numbers, a vector, is a 1D tensor. A grid of numbers, a matrix, is a 2D tensor.

AI often works with data that has more than two dimensions. For example, a colour image can be represented as a 3D tensor: height, width, and colour channels (red, green, and blue). A video clip could be a 4D tensor, adding the dimension of time. Tensors give us a consistent way to handle this multi-dimensional data.

Models process these tensors using mathematical operations. The dot product, for instance, is a fundamental operation. When you take the dot product of two vectors, you get a single number that reflects their relationship. If the vectors represent features of data, the dot product can measure their similarity. In a neural network, this is how inputs are combined and weighed to produce an output.

We also use matrix transformations. Multiplying a data vector by a specific matrix can rotate, scale, or shear it. This isn't just geometric trivia; it's how a neural network learns to manipulate and remap data from an input space to a feature space where patterns are easier to find.

Learning From Mistakes

How does a model know if it's learning? It measures its own errors. A cost function (or loss function) is a formula that calculates a single number representing how far off a model's prediction is from the correct answer. A high number means a big error; a low number means the model is getting close. The entire goal of training is to adjust the model's internal parameters to make the value of the cost function as small as possible.

This is an optimisation problem, and we solve it with calculus. Imagine the cost function as a hilly landscape, where the elevation at any point is the model's error. We want to find the lowest valley. To do that, we need to know which way is downhill.

The gradient gives us this information. It's a vector composed of partial derivatives. A partial derivative tells us how a tiny change in one single parameter—one knob on the model—affects the total error. The gradient bundles all these partial derivatives together and points in the direction of the steepest ascent on our error landscape. To get to the bottom of the valley, we just take small steps in the exact opposite direction of the gradient. This process is called gradient descent.

J(θ)=[Jθ1Jθ2Jθn]\nabla J(\theta) = \begin{bmatrix} \frac{\partial J}{\partial \theta_1} \\ \frac{\partial J}{\partial \theta_2} \\ \vdots \\ \frac{\partial J}{\partial \theta_n} \end{bmatrix}

In deep neural networks, the final cost is the result of many functions nested inside one another (the layers). To calculate the gradient here, we use the chain rule. It allows us to efficiently compute how much each parameter, in every layer, contributed to the final error. We can then pass this error information backwards through the network, from the output layer to the input layer, adjusting the parameters at each step. This is the mechanism behind backpropagation, the workhorse algorithm for training most deep learning models.

Handling Uncertainty

The world is rarely black and white. AI models need a way to quantify uncertainty and make predictions in noisy, unpredictable environments. This is the domain of probability theory.

A key tool here is Bayesian inference, a formal method for updating our beliefs when we encounter new evidence. It's built on a simple idea:

Updated Belief = (Initial Belief) × (Strength of New Evidence)

In Bayesian terms, our initial belief is called the prior probability. The strength of the new evidence is the likelihood. And our updated belief is the posterior probability. In machine learning, the 'belief' is about the best values for the model's parameters, and the 'evidence' is the training data we show it.

P(θD)=P(Dθ)P(θ)P(D)P(\theta | D) = \frac{P(D | \theta) \cdot P(\theta)}{P(D)}

This framework allows a model not just to make a prediction, but also to express its confidence in that prediction. To do this, models often assume that data follows a certain pattern, or distribution. A Gaussian distribution (the 'bell curve') is often used for continuous values like temperatures or prices. A Bernoulli distribution is used for binary outcomes, like whether an email is spam or not. By using these distributions, models can quantify uncertainty and make more nuanced, probabilistic predictions.

Quiz Questions 1/6

A colour image is represented as a 3D tensor. What do these three dimensions typically correspond to?

Quiz Questions 2/6

In the context of training a model, what does a cost function measure?

These three pillars—linear algebra, calculus, and probability—are the language used to design, train, and interpret AI models.