Functions & Graphs
P2.math-foundations.02 · Audience: guest, it-ml, language-pro · Prerequisites: Numbers & Computer Representations
A function is simply a rule that turns one number into another: you give it an input, it gives back an output. That is the whole idea, and it is the single most important tool in this tutorial. Every transformation inside a Transformer — the embedding lookup, attention, the feed-forward layer — is a function, and a small family of special functions (ReLU, sigmoid, tanh, softmax) shapes numbers at every layer. This module explains what functions are, how we picture them as graphs, and how chaining them together builds the entire model.
A function is a rule that turns one number (or set of numbers) into another. You give it an input, it hands back an output. That is all it is. You already use functions every day:
- A currency converter: input € 100 gives output $ 108.
- A thermometer: input 37 °C gives output 98.6 °F (rule: F = C × 9/5 + 32).
- A spell-checker: input a misspelled word gives output a corrected word.
In mathematics we write f(x) = some rule. The letter x is the input; f(x) is the output.
🗣️ From a linguist's perspective: Functions as rules that map inputs to outputs — like grammatical rules
ⓘ Concept: Functions — the core idea
Why it matters — Every transformation inside the Transformer is a function. The embedding lookup, the dot-product attention, the feed-forward layer — each is a function that takes a vector as input and returns a vector as output.
Three everyday functions, side by side over inputs from −3 to 3: f(x) = x² (a bowl-shaped curve), g(x) = 2x + 1 (a straight line), and h(x) = the absolute value of x (a V-shape). Each takes the same input and produces its own output.
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Try it yourself
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Where next?
Later in Mathematics Foundations