What Is a Matrix?
A matrix is just a grid of numbers. But it's secretly the most important object in all of AI and computational neuroscience — because a matrix is a machine that turns one list of numbers into another.
First — who are these neurons? Vision happens in two stages. Retinal neurons sit at the back of your eye and act as the sensors: like a smart camera, they catch light and pull out simple features — brightness, contrast, edges — then send signals x₁, x₂, x₃ to the brain through the optic nerve. Brain neurons (in the visual cortex) are the interpreters: each one listens to many retinal neurons at once, each connection with its own weight — strongly to one, only a little to another. A brain neuron's output is just that weighted sum of retinal signals — which is exactly the system of equations below.
Start with a system of equations. Say three retinal neurons drive three brain neurons, each output a weighted mix of the inputs:3x₁ + 2x₂ + x₃ = y₁7x₁ + x₂ + 2x₃ = y₂x₁ − x₂ − 2x₃ = y₃
Writing all those weights out every time is painful. So we pack them into a grid — a matrix W — and the whole system collapses to one clean line:
W x = y
W = the grid of weights. x = the input list (a vector). y = the output list. One matrix replaces the whole system of equations.
How the multiply works: each output entry is a dot product — one row of W combined with the input x. Row 1 of W · x gives y₁, row 2 · x gives y₂, and so on.
Your whole matrix toolkit in Python is just three functions:
• Build a matrix → np.array([[...], [...]]) (a list of rows)
• Multiply matrix × vector → W @ x (the @ symbol is matrix-multiply)
• Invert it (to decode) → np.linalg.inv(W)
That's it. The next lessons are just practice with these three.
import numpy as np# Build the weight matrix — a list of rowsW = np.array([[3, 2, 1], [7, 1, 2], [1, -1, -2]])x = np.array([1, 2, 3]) # retinal inputs (a vector)# Forward: brain outputs = weights @ inputsy = W @ x # '@' means matrix-multiplyprint("brain outputs y =", y)# Backward (decode): recover the inputs from the outputsx_back = np.linalg.inv(W) @ yprint("recovered inputs =", x_back) # → back to [1. 2. 3.]Press Run — W @ x sends inputs → outputs, and np.linalg.inv(W) @ y decodes them back. That round-trip IS what the next lessons practice.
🤖 Why AI researchers live in matrices: a single layer of a neural network is literally this equation — output = W x, where W is the layer's weights and x is the incoming activity. GPT is billions of these multiplies stacked up. Learn this one operation and you've learned the core of deep learning.
And it runs backwards too. If you know the weights W and the outputs y, you can sometimes recover the inputs x using the matrix inverse: x = W⁻¹ y. In neuroscience that's decoding — reading the stimulus back out of the brain's response. ("Sometimes" is the key word — you'll see why it fails soon.)