Log inStart free
LESSON 5.07 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

SwiGLU and gated MLPs

Watch a gate open and shut each hidden unit of an MLP.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 5.07 · GATE BAYPLAIN · 4 UNITS · 3 AT 0 · ŷ 0.92
01
Stage 1 of 6 · Plain MLP
A plain MLP sends x through 4 units with ReLU. At x = 1, ReLU sets 3 units to 0.
Explain it simply

On the left is the input x, one number, and each ochre ribbon is one weight. The four middle cells are hidden units after ReLU, which turns every negative number into zero. Here three units are zero, so they are dashed. The cell on the right is the output, the net's guess.

Input x is 1. It feeds 4 hidden units after ReLU and one output, 0.92. 3 units are 0.

Weights are random, not trained, until the last stage.
input, gate, value, pointsweights, dashed if negativehidden units, outputlosszero or shut
1.000.510.000.000.000.92plain MLPinput xReLU unitsoutput ŷw, bvŷ = Σ v·ReLU(w·x + b) + c · 13 weights · 3 of 4 units at 01.000.510.000.000.000.92plain MLPinput xReLU unitsoutput ŷw, bvŷ = Σ v·ReLU(w·x + b) + c · 13 weights · 3 of 4 units at 0
Toy: one input, 4 ReLU or 3–4 gated units
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
y^=∑jvj hj+c,hj=ReLU(wj x+bj)\sy{y}{out}{\hat y} = \sum_j \sy{w}{param}{v_j}\,\sy{a}{out}{h_j} + \sy{w}{param}{c},\quad \sy{a}{out}{h_j} = \mathrm{ReLU}(\sy{w}{param}{w_j}\,\sy{x}{data}{x} + \sy{w}{param}{b_j})
y^=1.80⋅0.51−0.11⋅0.00+0.32⋅0.00+0.27⋅0.00+0=0.92\hat y = 1.80\cdot 0.51 - 0.11\cdot 0.00 + 0.32\cdot 0.00 + 0.27\cdot 0.00 + 0 = 0.92

Each unit applies ReLU, and the output adds the weighted units.

Common mix-ups

MYTHThe gate is a fixed switch, like a ReLU unit.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Remove the activation from the gate. Can the net still fit the curve?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.