Chaining and undoing functions
Why this matters
Big rules are built from small ones: do one function, then feed its answer into the next. That's called composing, and a neural network is exactly that, a chain of simple functions, layer after layer. Running a chain backward is the inverse, and it's how data scaled for a model gets turned back into numbers people understand. You'll also see why some functions, like squaring and ReLU, can't be undone at all without a restriction. Every step is checked in Python.
- Compose functions, g(f(x)), and see why the order matters
- Find an inverse function by undoing each step in reverse, and check it
- Chain functions in Python, and check an inverse on a list of inputs with a loop
- See a neural network as a chain of functions, and undo a scaling step
The math: chains of machines
Purpose. Build big rules from small ones, and run rules backward.
Composing two functions means feeding the output of one into the other. g(f(x)) is read from the inside out: do f first, then g. Its other name is (g ∘ f)(x), "g after f".
Order matters. Doubling then adding 3 isn't the same as adding 3 then doubling: g(f(5)) = 13 but f(g(5)) = 16. Putting on socks then shoes is different from shoes then socks.
An inverse runs a function backward: it takes the output and gives back the input. The inverse of f is written f⁻¹. That little −1 doesn't mean "one over"; it means "undo".