1 00:00:01,000 --> 00:00:09,300 [Hal Turing] Alrighty! Thanks for tuning in! Hello AI world! I am your host, Hal Turing, and my co-host is Dr. Ada Shannon. 2 00:00:09,300 --> 00:00:35,900 [Hal Turing] Today's paper is "Backprop as Functor: A compositional perspective on supervised learning," by Brendan Fong, David Spivak and Rémy Tuyéras, from MIT. It appeared at IEEE in 2019, and the arXiv version we're reading is v3 from May 2019. The claim is that gradient descent on a whole network equals composing the gradient-descent learners of its parts, and that this is a theorem rather than a slogan. 3 00:00:35,900 --> 00:00:53,875 [Dr. Ada Shannon] One expectation up front: there are no experiments. No datasets, no accuracy numbers. The only concrete check is a symbolic algebra example. It's a structural paper, and what we should weigh is what that structure buys. The short version also leans on an extended version for the full proofs. 4 00:00:53,875 --> 00:01:01,525 [Hal Turing] So the question is: can learning algorithms compose, and does gradient descent respect that composition? 5 00:01:01,525 --> 00:01:22,025 [Dr. Ada Shannon] Yes. Take a learner from A to B and another from B to C. Composing the functions is easy: feed one into the other, and use both parameter sets together. Training is the hard part. The second learner trains on pairs (b, c), and you can build those from forward activations. The first learner needs pairs (a, b'), and your data never contains a b'. Nothing says what the intermediate target should be. 6 00:01:22,025 --> 00:01:26,175 [Hal Turing] Backprop answers that, though. Gradients flow backward. 7 00:01:26,175 --> 00:01:41,175 [Dr. Ada Shannon] Right. Backprop never differentiates the whole network at once. Each layer computes a local gradient and passes a signal backward. The paper turns that signal into an explicit part of the interface. It's called the request function. 8 00:01:41,175 --> 00:01:43,775 [Hal Turing] Define the learner for me. 9 00:01:43,775 --> 00:02:05,275 [Dr. Ada Shannon] A learner from A to B has four parts. P is a parameter space. I(p, a) is the implementation, the function you get at parameter p. U(p, a, b) is the update: given a training pair, it returns a new parameter. And r(p, a, b) is the request: given an input and a target output, it returns a revised input, the one this learner would have preferred to receive. For a layer, I is its output, U nudges its weights, and r says how its input should have been different. 10 00:02:05,275 --> 00:02:09,800 [Hal Turing] And composition uses the request as the missing b'. 11 00:02:09,800 --> 00:02:30,650 [Dr. Ada Shannon] Yes. Run the forward pass to get b = I(p, a). The downstream learner, with its parameters q, looks at b and the final target c. It returns a request b' = s(q, b, c). The upstream learner then updates on the pair (a, b'). The downstream learner updates on (b, c). Both updates use the old parameters p and q, so it's a simultaneous update, as in ordinary backprop. 12 00:02:30,650 --> 00:02:42,400 [Hal Turing] That sounds like difference target propagation, where layers get local targets instead of gradients. Lee, Zhang, Fischer and Bengio, from Bengio's group, 2015. 13 00:02:42,400 --> 00:03:00,775 [Dr. Ada Shannon] It's the closest mainstream relative. Both ask how a downstream module tells an upstream one what it should have produced. The difference is that this paper proves that, for gradient descent, the request-based scheme equals backprop, at least in the setting it covers. Target propagation is an approximation. 14 00:03:00,775 --> 00:03:04,275 [Hal Turing] Now the category theory. Keep it plain. 15 00:03:04,275 --> 00:03:26,525 [Dr. Ada Shannon] A category is things plus ways to chain them. Objects, arrows between them, chaining that is associative, and an identity arrow for each object. A functor translates one category into another while preserving chaining. Functoriality means that translating then chaining gives the same result as chaining then translating. Monoidal means you can also put things side by side, so you get parallel as well as sequential composition. 16 00:03:26,525 --> 00:03:29,450 [Hal Turing] So two categories matter here. 17 00:03:29,450 --> 00:04:00,775 [Dr. Ada Shannon] Para and Learn. Para holds differentiable parametrised functions between Euclidean spaces, of the form P × R^n → R^m. Composing two of them pairs up the parameters: the composite takes p and q, and runs the first function and then the second. Morphisms are identified up to a differentiable, invertible reparametrisation of P. Learn holds the learners, with the composition rule I described. Composition there is only associative up to an isomorphism of parameter sets, so morphisms are equivalence classes of learners. 18 00:04:00,775 --> 00:04:02,500 [Hal Turing] And the theorem? 19 00:04:02,500 --> 00:04:39,000 [Dr. Ada Shannon] Informally: fix a step size ε and an error function e whose derivative with respect to its first argument, ∂e/∂x at x0, is invertible as a function of y. Then there is a faithful, injective-on-objects, strong symmetric monoidal functor from Para to Learn. It sends a parametrised function I to a learner whose update is p minus ε times the gradient of the error in p, and whose request is the inverse f_a applied to the gradient of the error in the input. Gradient descent supplies the update, and backprop supplies the request. 20 00:04:39,000 --> 00:04:47,149 [Hal Turing] There's also a family resemblance to lenses and open games. A lens pairs a forward get with a backward put. 21 00:04:47,149 --> 00:05:05,125 [Dr. Ada Shannon] Right, and the paper says the request plays the role of put in lenses and coplay in open games, with sketched embeddings of lenses into learners and learners into games. We'll come back to how precisely that holds. The point for now is that the forward and backward pair is the basic building block. 22 00:05:05,125 --> 00:05:07,875 [Hal Turing] So what's the catch you're hinting at? 23 00:05:07,875 --> 00:05:26,274 [Dr. Ada Shannon] The proof sketch says the result amounts to observing that the chain rule is functorial. Part of this paper's value is making that observation precise. Whether the precision buys anything beyond restating the chain rule is the question I'd hold until we've seen the mechanism and the worked example. 24 00:05:26,274 --> 00:05:36,024 [Hal Turing] Then let's look at the mechanism. Take quadratic error. Why does the composite update come out equal to plain gradient descent on the whole network? 25 00:05:36,024 --> 00:06:14,549 [Dr. Ada Shannon] Because of one choice: the downstream learner's request is evaluated at the current output. Walk it as a chain. The first layer produces b equal to I of p and a. The second learner J computes its error against c and hands back b prime, which is b minus the gradient of J's error with respect to b. Now the first layer trains toward b prime. Its local gradient is I of p and a minus b prime, times the derivative of I with respect to p. That difference is exactly the gradient of J's error with respect to b. So the first layer's local update is the gradient of J's error times dI by dp. That's the chain rule term. 26 00:06:14,549 --> 00:06:18,999 [Hal Turing] So nobody ever builds the gradient of the whole network. 27 00:06:18,999 --> 00:06:22,924 [Dr. Ada Shannon] Right. Each learner computes its own gradient from a target. 28 00:06:22,924 --> 00:06:28,224 [Hal Turing] Something looks off, though. The update has epsilon, but the request doesn't. 29 00:06:28,224 --> 00:06:53,149 [Dr. Ada Shannon] That's Remark III.5. Under quadratic error the request looks like an update without epsilon, and the paper says that's a coincidence. For a general error function e, the request applies the inverse of the partial derivative of e in its first argument to the gradient. The inverse turns a gradient into a corrected input, a value the upstream learner can use as a target. The interface only lets you pass back a value in the domain, not a gradient. That's why the theorem needs invertibility. 30 00:06:53,149 --> 00:06:56,250 [Hal Turing] And neural networks fit into this how? 31 00:06:56,250 --> 00:07:15,850 [Dr. Ada Shannon] In two steps. An activation sigma sends a network architecture to a parametrised function. That's Proposition IV.2. Then the epsilon-and-error choice sends that to a learner. The composite says a network is a compositional learning algorithm. There's a factoring through directed acyclic graphs, but it's a side detail. 32 00:07:15,850 --> 00:07:19,150 [Hal Turing] Section V is where neurons show up. 33 00:07:19,150 --> 00:07:40,475 [Dr. Ada Shannon] Yes. Copy and merge wires get learner semantics by inheriting them from linear maps through the functor. Under quadratic error, merge hands back to its two inputs the third value minus the other input. Copy returns the sum of the two requests minus the original. With three generators, scalar multiply, bias, and activation, plus copy and merge, a neuron is multiplies, merge, activation, copy. 34 00:07:40,475 --> 00:07:43,100 [Hal Turing] Weight tying falls out of that? 35 00:07:43,100 --> 00:07:59,050 [Dr. Ada Shannon] It does, and it's the most concrete payoff. A shared parameter wire splits, feeds both uses, and updates on the sum of the requests from both. That's what convolution needs. The paper derives it from the copy rule instead of adding a special case. 36 00:07:59,050 --> 00:08:06,900 [Hal Turing] Now the worked example. A 2-2-1 network, split into a 2-to-2 layer B and a 2-to-1 layer C. 37 00:08:06,900 --> 00:08:27,825 [Dr. Ada Shannon] The claim is that the whole network's update and request equal the composition of the two layers' learners. The paper checks only one coordinate, p11, and it works. The chain runs through the output term gamma, which layer C hands back to layer B. Factoring reuses gamma and the hidden pre-activations, and the two layers can compute in parallel. That is the whole demonstration. 38 00:08:27,825 --> 00:08:31,400 [Hal Turing] Only one coordinate, and the text has slips? 39 00:08:31,400 --> 00:09:04,600 [Dr. Ada Shannon] Yes, and they're checkable against the PDF. In the whole-network update, the bias row for hidden node 2 scales by q1. It should be q2, since that node feeds the output through q2. In the first formula for r_B, the parentheses are misplaced and the second row has a stray sigma around a difference. In U_B, the first bias row uses the second output's error, where it should use the first. The second bias row is right. Also, r_A includes an epsilon while r_B and r_C don't, and the theorem's request has none. And U_C is typed as landing in R2 when it should be R3. 40 00:09:04,600 --> 00:09:07,200 [Hal Turing] Do we trust the verdict now? 41 00:09:07,200 --> 00:09:12,875 [Dr. Ada Shannon] I'm holding that for the end. For now it's a technical detail about the illustration. 42 00:09:12,875 --> 00:09:17,600 [Hal Turing] What about cross entropy? Everyone trains classifiers with it. 43 00:09:17,600 --> 00:09:39,350 [Dr. Ada Shannon] Section VII-A handles it awkwardly. The written form is y ln x plus one minus y times ln of one minus x. There's no leading minus, so as written it's a log-likelihood, not a loss to minimise. The stated derivative, y minus z over z times one minus z, matches that unsigned form. The standard loss is the negative, with z minus y on top. The paper doesn't comment on the sign. 44 00:09:39,350 --> 00:09:42,125 [Hal Turing] And the invertibility condition? 45 00:09:42,125 --> 00:10:09,475 [Dr. Ada Shannon] It fails at outputs of exactly zero and one, because the derivative is undefined there. For z strictly between zero and one, it's linear in y with slope one over z times one minus z, so it's invertible. The patch is to restrict data and outputs to the open interval and assume a small epsilon keeps outputs inside it. The usual averaged error needs an extra variable, treated only in the extended version's appendix. The paper concedes this is not straightforward to state as a functor from Para. 46 00:10:09,475 --> 00:10:13,649 [Hal Turing] Last piece is the lens and open game connection. 47 00:10:13,649 --> 00:10:45,424 [Dr. Ada Shannon] The paper's claim is that asymmetric lenses are learners with trivial state, and learners are open games with a singleton best-response condition. Lens embeds in Learn, which embeds in Game. Request plays put and coplay, implementation plays get and play, and update plays best response. The paper only sketches this. Hedges, in From Open Learners to Open Games from 2019, makes the game side precise, and Fong and Johnson, Lenses and Learners, 2019, does the lens side. The open-games source is Ghani, Hedges, Winschel and Zahn, Compositional Game Theory, from LICS 2018. 48 00:10:45,424 --> 00:10:57,500 [Hal Turing] Here's the question I've been holding. The proof sketch says the theorem amounts to observing that the chain rule is functorial. So is this more than the chain rule in nicer clothes? 49 00:10:57,500 --> 00:11:36,700 [Dr. Ada Shannon] Computationally, no. It gives you no new algorithm, no measured speedup, and no prediction you could falsify. A reader who already knows autodiff learns nothing new about what backprop computes. What it adds is architectural, and I'd count four things. First, the learner interface makes 'local training from global data' a precise statement. Second, strong monoidality means you can cut a network into subunits any way you like, not just layer by layer, and get the same update. Third, the update and the request are separate roles, and invertibility of the error derivative is exactly the condition for an error to be passable backward as a target. Fourth, Learn is bigger than the image of Para, so in principle non-gradient learners can be dropped in. 50 00:11:36,700 --> 00:11:44,575 [Hal Turing] That last one sounds like the part that should pay off. Does the paper show a non-gradient learner that actually learns? 51 00:11:44,575 --> 00:12:05,875 [Dr. Ada Shannon] No. And Learn has no convergence or well-behavedness condition, which the authors admit in the discussion. Without one, Learn is a category of arbitrary tuples, and composing locally sensible learners guarantees nothing about global behavior. Target propagation is the natural practical test of whether a non-gradient scheme can work, and the paper doesn't run it. 52 00:12:05,875 --> 00:12:13,725 [Hal Turing] Then the evidence. One coordinate, p11, checked symbolically, with the slips you found. How worried should I be? 53 00:12:13,725 --> 00:12:35,325 [Dr. Ada Shannon] Not very, about the general machinery. The slips are in the illustration, not the definitions, and the theorem rests on the chain rule, which isn't in doubt. But it's the only concrete check in the paper, and a single coordinate can't catch errors in the other rows. A ten-line numeric gradient check against an autodiff library would have caught them. The short version doesn't say anyone did that. That's an inference from silence, and the extended version may say more. 54 00:12:35,325 --> 00:12:39,250 [Hal Turing] What about scope? Can I train a modern network with this? 55 00:12:39,250 --> 00:13:08,524 [Dr. Ada Shannon] The theorem as stated, no. It needs an invertible error derivative, which is essentially quadratic error. Cross entropy fails at 0 and 1, and the patch assumes outputs stay strictly inside (0,1) with a small enough step, with no proof that they do. The update is one plain gradient step per datum, so there are no minibatches, no momentum, no Adam. And Para requires differentiable maps between Euclidean spaces, so ReLU at zero, max-pooling and top-k routing aren't covered. The paper doesn't claim subgradient or straight-through extensions, and I wouldn't assume them. 56 00:13:08,524 --> 00:13:13,299 [Hal Turing] What about the claim that composition explains backprop's speedup? 57 00:13:13,299 --> 00:13:33,324 [Dr. Ada Shannon] That's an assertion, not an analysis. Reverse-mode speed comes from reusing intermediate products and the cost asymmetry between reverse and forward mode, which the Baydin, Pearlmutter, Radul and Siskind survey from 2018 lays out. Functoriality only says local composition equals the global gradient. It says nothing about cost. 58 00:13:33,324 --> 00:13:42,350 [Hal Turing] Also, the request under non-quadratic error is a transformed gradient. Is it still the input the layer would have preferred? 59 00:13:42,350 --> 00:14:04,225 [Dr. Ada Shannon] Not literally. Under general error it's a corrected-input target built by inverting the error derivative, and the paper doesn't check that it stays in a valid range, say outside (0,1) for sigmoid outputs. The dreaming analogy, citing Mahendran and Vedaldi's 2015 image-inversion work, is also looser than it sounds. Inversion optimizes the input over many steps, and the request is a single-step quantity. 60 00:14:04,225 --> 00:14:06,950 [Hal Turing] So what should someone read next? 61 00:14:06,950 --> 00:14:38,350 [Dr. Ada Shannon] Categorical Foundations of Gradient-Based Learning, by Cruttwell, Gavranović, Ghani, Wilson and Zanasi, ESOP 2022. It swaps learners for parametrised lenses over reverse-derivative categories, so stateful optimizers like momentum and Adam and non-quadratic losses are handled by the lens backward pass instead of an invertible error derivative. Reverse Derivative Categories, by Cockett and coauthors in 2020, supplies the abstract differentiation underneath. And for the lens and game claims, the Fong–Johnson and Hedges papers I mentioned are where they're made precise. 62 00:14:38,350 --> 00:14:43,025 [Hal Turing] And the larger blind spot, beyond the losses and optimizers? 63 00:14:43,025 --> 00:15:01,300 [Dr. Ada Shannon] Anything non-local. Global gradient-norm clipping and second-order methods use the backward channel for more than a per-layer message. Also, composing local rules doesn't ensure good global learning. This formalism sidesteps that question, because the local rules happen to equal the gradient. 64 00:15:01,300 --> 00:15:03,875 [Hal Turing] Who does this affect today? 65 00:15:03,875 --> 00:15:26,300 [Dr. Ada Shannon] Mostly people building frameworks or studying compositional structure, not people tuning training runs. It gives a vocabulary for modular training and a way to ask what a legitimate new primitive is. The paper pitches richer primitives, different error notions per sub-network, a bicategory for architecture changes, and links to bidirectional programming. All of that is a future direction, and none of it is demonstrated empirically. Practitioners shouldn't change anything. 66 00:15:26,300 --> 00:15:28,625 [Hal Turing] And where does it go from here? 67 00:15:28,625 --> 00:15:51,550 [Dr. Ada Shannon] The paper names three directions. First, error functions that fail differentiability at isolated points. Second, a bicategory of learners for architecture search. Third, connecting lens laws to learners that actually converge. Categorical Deep Learning, from Gavranović, Lessard, Dudzik, von Glehn, Araújo and Veličković in 2024, pushes further, toward saying something about architectures themselves. This paper's view stops at training. 68 00:15:51,550 --> 00:16:15,975 [Hal Turing] Let me close the loop. The paper gives a clean compositional interface in which backprop is a functor, under quadratic error and invertible error derivatives. The boundary is that it restates the chain rule structurally. It shows no computational or empirical advantage, its one example has checkable slips, and its optimizer and loss coverage is narrow. Thanks for listening, everyone. 69 00:16:15,975 --> 00:16:17,550 [Dr. Ada Shannon] Thanks, everyone.