Advanced Mathematics

Neural Networks

Layers of simple units, each a weighted sum passed through a nonlinear function, composed into a function that can fit almost anything.

Needs a step first: 33

A layer computes h⃗=ϕ(Wx⃗+b⃗)\vec h = \phi(W\vec x + \vec b): a matrix multiplication, a shift, then a nonlinearity such as ReLU, ϕ(z)=max⁡(0,z)\phi(z) = \max(0, z), applied to each entry; stacking layers lets the network build features out of features. Without the nonlinearity the layers would collapse into one matrix, so a deep linear network can do no more than linear regression. With it, even one hidden layer can approximate any reasonable function given enough units. The weights are learned by backpropagation and gradient descent, and the same building blocks make up convolutional networks and transformers.

Where it shows up: Backpropagation trains them, and convolutional networks, embeddings and transformers are neural networks with particular structure.

How to hold it: In your head

See a layer as multiply by a matrix, shift, then bend with a nonlinearity, and why without the bend any stack of layers collapses into one matrix.

What knowing it looks like

  • Compute the output of a small two-layer ReLU network by hand, layer by layer.
  • Show that two linear layers without an activation equal one linear layer.
  • Count the parameters of a fully connected network from its layer sizes.

Test yourself

A network has hidden units h1=ReLU(x1+x2)h_1 = \mathrm{ReLU}(x_1 + x_2) and h2=ReLU(x1+x2−1)h_2 = \mathrm{ReLU}(x_1 + x_2 - 1) and output y=h1−2h2y = h_1 - 2h_2. Compute yy for the inputs (0,0)(0, 0), (0,1)(0, 1), (1,0)(1, 0), (1,1)(1, 1). What function is it, and why can no single linear unit y=w1x1+w2x2+by = w_1x_1 + w_2x_2 + b followed by a threshold compute it?
Show the worked answer
(0,0)(0, 0): h=(0,0)h = (0, 0), y=0y = 0. (0,1)(0, 1) and (1,0)(1, 0): h=(1,0)h = (1, 0), y=1y = 1. (1,1)(1, 1): h=(2,1)h = (2, 1), y=2−2=0y = 2 - 2 = 0. So it computes XOR. A single unit with a threshold splits the plane with one straight line, but the points where XOR is 1, (0,1)(0, 1) and (1,0)(1, 0), sit on opposite corners from (0,0)(0, 0) and (1,1)(1, 1), and no line separates them. The hidden layer bends the space so it becomes possible.

Needs a step first: 33

Learn it with an AI

Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.

Be my maths tutor. I'm learning "Neural Networks" (Frontier tier): Layers of simple units, each a weighted sum passed through a nonlinear function, composed into a function that can fit almost anything.
I already know: Logistic Regression and Classification, Matrices as Transformations.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: A network has hidden units $h_1 = \mathrm{ReLU}(x_1 + x_2)$ and $h_2 = \mathrm{ReLU}(x_1 + x_2 - 1)$ and output $y = h_1 - 2h_2$. Compute $y$ for the inputs $(0, 0)$, $(0, 1)$, $(1, 0)$, $(1, 1)$. What function is it, and why can no single linear unit $y = w_1x_1 + w_2x_2 + b$ followed by a threshold compute it?
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.

On the way to

Recommended