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:37,900 [Hal Turing] Today's paper is "Averaging Weights Leads to Wider Optima and Better Generalization," first posted to arXiv in 2018 and revised in 2019. Pavel Izmailov is the first author, with Andrew Gordon Wilson as senior author, and the work spans Cornell and several Moscow labs, including the Higher School of Economics and Samsung AI Center. The claim is that if you stop shrinking the learning rate and just average the weights SGD visits, you get a better single model. 3 00:00:37,900 --> 00:00:57,125 [Dr. Ada Shannon] And you get something close to an ensemble at single-model cost. The question is whether a plain equal-weight average of weights, collected under a high or cyclical learning rate, lands in a wider, more central part of the loss surface, and whether that beats ordinary decaying-rate SGD. Before we judge it, we need the background. 4 00:00:57,125 --> 00:01:06,450 [Hal Turing] Start with why anyone would do this. Standard training decays the learning rate to nearly zero. That seems sensible. What's wrong with it? 5 00:01:06,450 --> 00:01:26,425 [Dr. Ada Shannon] Nothing is wrong, but it settles on one point. Picture a bowl-shaped region of good solutions. With a high learning rate, SGD keeps bouncing around the rim and never reaches the middle. Decay forces it to stop somewhere on that rim. The paper's idea is to let it bounce and then average the positions, because the average of points on a rim sits near the center. 6 00:01:26,425 --> 00:01:30,875 [Hal Turing] Why would a bowl exist at all? I'd expect isolated pits. 7 00:01:30,875 --> 00:01:50,975 [Dr. Ada Shannon] That's mode connectivity. Garipov and colleagues, 2018, and Draxler and colleagues, 2018, found that two independently trained networks can be joined by a simple curve along which the loss stays nearly constant. A straight line between them usually crosses a barrier. So good solutions form a connected, curved region rather than separate islands. 8 00:01:50,975 --> 00:01:55,050 [Hal Turing] And Garipov's team built something on top of that. 9 00:01:55,050 --> 00:02:16,025 [Dr. Ada Shannon] Fast Geometric Ensembling, or FGE. It uses a rapidly cycling learning rate to collect several nearby networks from one training run, typically six to twelve. Their predictions differ enough to be useful as an ensemble. The SWA paper's Figure 1 shows those FGE points sitting on the periphery of the good region. That suggested averaging them in weight space. 10 00:02:16,025 --> 00:02:21,025 [Hal Turing] Why does the ensemble matter? Just ask the six models and average. 11 00:02:21,025 --> 00:02:36,051 [Dr. Ada Shannon] Because test-time cost scales linearly. Six models cost six times the compute and memory at serving time. A single model that behaves like the ensemble keeps the accuracy and drops that multiplier. That's the appeal. 12 00:02:36,051 --> 00:02:41,001 [Hal Turing] Now the "wider optima" part of the title. What does wide mean here? 13 00:02:41,001 --> 00:03:03,101 [Dr. Ada Shannon] How far you must move in weight space before the loss rises by a given amount. The argument goes back to Hochreiter and Schmidhuber, 1997, and Keskar and colleagues, 2017, showed large-batch training tends to find sharper minima with worse test error. The mechanism is that train loss and test error surfaces are shifted relative to each other. A narrow minimum is fragile under that shift, while a point near the middle of a wide region stays good. 14 00:03:03,101 --> 00:03:06,127 [Hal Turing] So wide is better, case closed. 15 00:03:06,127 --> 00:03:28,402 [Dr. Ada Shannon] Not closed. Chaudhari and colleagues' Entropy-SGD, 2017, found wider optima, but generalization was only comparable. And Dinh and colleagues, 2017, showed that in ReLU and BatchNorm networks you can rescale layers without changing the function, which changes naive weight-space width. So no known sharpness definition explains generalization on its own. Hold that tension, because it affects how much weight the title can carry. 16 00:03:28,402 --> 00:03:33,552 [Hal Turing] Okay, held. Now the schedule piece, since the whole method lives there. 17 00:03:33,552 --> 00:03:54,227 [Dr. Ada Shannon] A decaying schedule starts large and shrinks. A constant schedule stays high. A cyclical one is a sawtooth: it ramps down from a high rate to a low one over a cycle, then jumps back up. This paper's cycle is deliberately discontinuous, jumping straight from the low rate to the high one. That favors exploration over making each individual iterate accurate. 18 00:03:54,227 --> 00:03:58,702 [Hal Turing] So individual iterates may be mediocre on purpose. 19 00:03:58,702 --> 00:04:18,927 [Dr. Ada Shannon] Yes, and you'll want to remember that. The familiar cousin is the exponential moving average of weights, which weights recent iterates heavily and usually rides along with a decaying rate. The paper says EMA behaves much like conventional SGD, while SWA uses equal weights under a high rate. We'll check how well that claim is supported. 20 00:04:18,927 --> 00:04:23,753 [Hal Turing] Where does SWA stand relative to classical averaging? 21 00:04:23,753 --> 00:04:39,003 [Dr. Ada Shannon] Polyak and Juditsky, 1992, showed that averaging SGD iterates gives the optimal rate in convex problems. SWA borrows the spirit of that, but applies it to a high-rate trajectory in a non-convex network. 22 00:04:39,003 --> 00:04:41,828 [Hal Turing] So what should listeners track next? 23 00:04:41,828 --> 00:05:03,454 [Dr. Ada Shannon] Three claims: an accuracy gain, a width story, and the ensemble approximation. And one question underneath all three, which is whether the baseline is fair. I'll leave that as a question for now. One forward pointer: the same group's follow-on, SWAG, by Maddox, Garipov, Izmailov, Vetrov, and Wilson in 2019, "A Simple Baseline for Bayesian Uncertainty in Deep Learning," extends this idea, and we'll come back to it near the end. 24 00:05:03,454 --> 00:05:09,954 [Hal Turing] Let's get the recipe down. If I wanted to run SWA tomorrow, what do I actually do? 25 00:05:09,954 --> 00:05:43,129 [Dr. Ada Shannon] Four steps. First, train with your usual schedule for about three quarters of the budget, then stop. Don't touch the schedule. Second, continue at a high constant learning rate, or a cyclical one for PyramidNet and Shake-Shake, so SGD wanders around the good region. Third, once per epoch, fold the current weights into a running equal-weight average. That's a weighted sum of two weight vectors. Fourth, run one pass over the training data to rebuild the BatchNorm statistics, because the averaged weights were never a network SGD actually visited. Their old statistics don't match. 26 00:05:43,129 --> 00:05:44,729 [Hal Turing] And the cost? 27 00:05:44,729 --> 00:05:55,904 [Dr. Ada Shannon] One extra copy of the weights, and an update at most once per epoch against hundreds of gradient steps. The paper puts the memory overhead on the order of ten percent. 28 00:05:55,904 --> 00:05:59,929 [Hal Turing] Why average at all? Why not just keep the last iterate? 29 00:05:59,929 --> 00:06:20,829 [Dr. Ada Shannon] Because the last iterate sits on the rim. Mandt and colleagues, 2017, showed that constant-learning-rate SGD behaves roughly like sampling from a Gaussian around the minimum. In high dimensions, samples from a Gaussian sit on a shell and almost never at the center. The average of many samples converges to the center, which is the convex result I mentioned from Polyak and Juditsky. 30 00:06:20,829 --> 00:06:24,204 [Hal Turing] But neural net losses aren't convex. 31 00:06:24,204 --> 00:06:35,904 [Dr. Ada Shannon] Right. The proof needs convexity, and the paper only argues the loss is approximately convex along SGD trajectories. So that's motivation, not a guarantee. 32 00:06:35,904 --> 00:06:38,229 [Hal Turing] Then what do they measure? 33 00:06:38,229 --> 00:07:07,504 [Dr. Ada Shannon] First, Figure 3. They take a plane through three points on a PreResNet-164 trajectory on CIFAR-100. Cyclical-rate proposals are individually accurate. Constant-rate proposals are individually worse but cover more ground. And the train loss and test error surfaces look similar but shifted. That shift is the argument for a central point. If the test surface is offset from the train surface, the middle of a broad region stays good under the offset, and a point near the edge doesn't. 34 00:07:07,504 --> 00:07:14,054 [Hal Turing] Now the word in the title. Is "wide" something they measure, or an interpretation of a plot? 35 00:07:14,054 --> 00:07:44,504 [Dr. Ada Shannon] It's a measurement along chosen directions, interpreted as width. In Figure 4 they draw ten random rays from each solution and track loss and error as you step away. Concretely, wide means you have to walk farther before the error climbs by a fixed amount. SGD's train loss is slightly lower at the start, SWA has better test accuracy, and SWA's curves are wider. The extracted text says SGD's test error is lower by 1.5 percent, which reads as a typo for SWA. 36 00:07:44,504 --> 00:07:48,704 [Hal Turing] So SWA fits the training data a bit worse? 37 00:07:48,704 --> 00:08:07,954 [Dr. Ada Shannon] Often, yes. It isn't a local optimum of the loss, and the paper says so. Figure 5 adds a line segment between the SGD and SWA solutions. The loss is asymmetric: SGD sits at the edge of a steep ascent, SWA near the middle of a flat stretch. And they're in the same basin, not different minima. 38 00:08:07,954 --> 00:08:12,679 [Hal Turing] What about the ensemble link? That's the claim I care about for cost. 39 00:08:12,679 --> 00:08:41,329 [Dr. Ada Shannon] The argument is a linearization. When proposals are close together, averaging the weights and averaging the predictions differ only at second order in the distances. The gap between individual proposals is first order. Then they check it on PreResNet-164, CIFAR-100. Two consecutive FGE snapshots disagree on the label for at least about one test image in eight, 12.7 percent or more. The SWA model and the whole FGE ensemble agree on about 95 out of 100. 40 00:08:41,329 --> 00:08:45,454 [Hal Turing] That's a direct test, not just a plot. What's the limit? 41 00:08:45,454 --> 00:08:51,329 [Dr. Ada Shannon] One architecture, one dataset, and a local approximation that needs small distances. 42 00:08:51,329 --> 00:08:54,679 [Hal Turing] Then the accuracy. What does a user get? 43 00:08:54,679 --> 00:09:34,029 [Dr. Ada Shannon] At the paper's one-budget setting, SWA beats the SGD baseline in all six architecture-dataset pairs. On CIFAR-100 with PreResNet-164, SGD gets 78.5 images right out of a hundred and SWA gets 79.8. That's about one more correct image per hundred, and SWA's run-to-run spread is about half of SGD's, 0.17 against 0.36. On CIFAR-10 the gains at one budget are only about 0.3 points, with spreads around 0.1. The text claims roughly half a point on average, but that mostly shows up at the larger budgets. There are three seeds and no significance test. 44 00:09:34,029 --> 00:09:36,479 [Hal Turing] And against the ensemble? 45 00:09:36,479 --> 00:09:58,829 [Dr. Ada Shannon] On CIFAR-10, SWA slightly beats FGE at one budget. On CIFAR-100 it's close for VGG and PreResNet. Wide ResNet is the counterexample: 81.46 for SWA against 82.27 for FGE. That 0.81-point gap closes only at 1.5 budgets. So "matches an ensemble" usually means more than the headline budget. 46 00:09:58,829 --> 00:10:03,029 [Hal Turing] Is there anything that isolates the averaging itself? 47 00:10:03,029 --> 00:10:28,754 [Dr. Ada Shannon] The from-scratch run. Wide ResNet-28-10 on CIFAR-100, constant learning rate 0.05, 300 epochs, averaging from epoch 140. The individual iterates sit around 65 percent accuracy. Their average scores 81.7. That's about sixteen points above any ingredient. It's a single run with no standard deviation, and the paper doesn't recommend training this way. It still shows the average is far better than its members. 48 00:10:28,754 --> 00:10:32,104 [Hal Turing] Can I just pick any constant learning rate? 49 00:10:32,104 --> 00:11:10,004 [Dr. Ada Shannon] Section 4.3 tested constants of 0.1, 0.05, 0.01 and 0.001, plus cyclical pairs, starting from a 125-epoch SGD model. Aggressive constants converge faster. The best was an intermediate value between the largest and smallest rates of the annealing range. That's also where the SWA hyperparameters come from. ImageNet is set up the same way: pretrained torchvision ResNet-50, ResNet-152 and DenseNet-161, ten SWA epochs, gains of roughly 0.6 to 0.9 points. I'll leave interpreting that. 50 00:11:10,004 --> 00:11:13,554 [Hal Turing] Because it's the baseline question you flagged. 51 00:11:13,554 --> 00:11:18,879 [Dr. Ada Shannon] Yes. Hold the gain numbers loosely until we've looked at what SGD was given. 52 00:11:18,879 --> 00:11:23,804 [Hal Turing] So does the one-budget comparison give SGD a fair shot? 53 00:11:23,804 --> 00:11:51,729 [Dr. Ada Shannon] Not demonstrably. SWA starts from a run stopped at about three quarters of the budget, then spends the last quarter at a constant learning rate the authors chose. The SGD baseline is a hand-written schedule: constant to half the budget, linear decay to one percent of the starting rate by 0.9, then flat. At 0.75 that schedule is still mid-decay, about 38 percent of its starting rate. So SWA doesn't start from a converged model, and the baseline isn't a tuned one either. 54 00:11:51,729 --> 00:11:54,254 [Hal Turing] And the extra-budget columns? 55 00:11:54,254 --> 00:12:15,379 [Dr. Ada Shannon] SWA at 1.25 and 1.5 budgets is compared against SGD at one budget. But the paper defines budget as the point where SGD stops improving, and never shows SGD at 1.25 or 1.5 with a tuned schedule. It also never shows a tuned EMA. The claim that EMA performs comparably comes with no numbers, so I can't evaluate it. 56 00:12:15,379 --> 00:12:21,329 [Hal Turing] Is there a result that says averaging itself matters, not just extra training? 57 00:12:21,329 --> 00:12:42,729 [Dr. Ada Shannon] Yes, the from-scratch run: iterates around 65 percent average to 81.7, which extra tuning of any one iterate doesn't obviously explain. Direction is also consistent in all six CIFAR rows at one budget. What I won't grant is the size on CIFAR-10. That's about 0.3 points with standard deviations around 0.1, and no significance test. 58 00:12:42,729 --> 00:12:44,904 [Hal Turing] What about ImageNet? 59 00:12:44,904 --> 00:13:03,829 [Dr. Ada Shannon] The baseline is a pretrained torchvision checkpoint with no reported spread. SWA gets ten more epochs. For ResNet-50, 76.15 goes to 76.97, but the baseline never receives those epochs. A fine-tuning control with the same ten epochs would settle it. 60 00:13:03,829 --> 00:13:08,779 [Hal Turing] Also, the learning rates change per architecture. How were they chosen? 61 00:13:08,779 --> 00:13:18,604 [Dr. Ada Shannon] The paper says a small grid, but not whether on test or validation data. If it was test, the gains are optimistic. We can't tell from the paper. 62 00:13:18,604 --> 00:13:23,279 [Hal Turing] Now the title's claim. Is the wider-optima evidence solid? 63 00:13:23,279 --> 00:13:57,004 [Dr. Ada Shannon] It's suggestive. Figure 4 is mostly PreResNet-164 on CIFAR-100, ten random rays, plotting loss against distance. Dinh and colleagues showed that in ReLU and BatchNorm networks you can rescale layers without changing the function, so width along weight-space rays isn't invariant. A wider-looking curve might partly reflect scale. The paper reports no weight norms, so I can't tell whether averaging changed the scale. That's a missing control, not a demonstrated bug. The paper itself says wider only along random directions, and Figure 5 shows steep directions for both points. 64 00:13:57,004 --> 00:13:59,779 [Hal Turing] What would a stronger test look like? 65 00:13:59,779 --> 00:14:15,079 [Dr. Ada Shannon] A scale-invariant or reparametrization-aware sharpness measure, more architectures, more rays. And the paper notes SWA's train loss is often slightly worse. That fits the shift argument, but it doesn't prove width causes the gain. 66 00:14:15,079 --> 00:14:17,404 [Hal Turing] So what is established? 67 00:14:17,404 --> 00:14:39,904 [Dr. Ada Shannon] An accuracy gain over the paper's baselines, and an ensemble link: label agreement of 95.26 percent between the SWA model and the FGE ensemble, against at most 87.33 between consecutive FGE proposals. The caveat is that agreement isn't accuracy, and in Table 1 SWA at one budget trails FGE on WRN CIFAR-100. Width is the weakest leg. 68 00:14:39,904 --> 00:14:44,154 [Hal Turing] Much of this comes from Garipov's earlier paper, right? 69 00:14:44,154 --> 00:15:05,804 [Dr. Ada Shannon] Yes. That 2018 paper gave FGE, mode connectivity, the BatchNorm pass and the budget definitions, so SWA inherits its baselines. The follow-on, SWAG, fits a Gaussian to the iterates, using the SWA mean plus a low-rank-plus-diagonal covariance, to get uncertainty. That's outside this paper's evidence. This paper measures only accuracy, not calibration. 70 00:15:05,804 --> 00:15:12,204 [Hal Turing] Everything tested is CNNs with BatchNorm and SGD. What about transformers? 71 00:15:12,204 --> 00:15:17,879 [Dr. Ada Shannon] Untested here. The paper gives no evidence either way, so I wouldn't extrapolate. 72 00:15:17,879 --> 00:15:20,154 [Hal Turing] What should a practitioner do? 73 00:15:20,154 --> 00:15:41,129 [Dr. Ada Shannon] If ensemble cost is the problem, SWA is a cheap end-of-training addition: one extra weight copy, one BatchNorm pass, single-model inference. The paper advises starting from a conventionally trained model, and picking a rate between the largest and smallest annealing rates. Then run the control the paper skipped: the same extra epochs without averaging. 74 00:15:41,129 --> 00:15:43,979 [Hal Turing] And the authors' future directions? 75 00:15:43,979 --> 00:15:59,029 [Dr. Ada Shannon] Proposals, not results: faster convergence, since iterates needn't be good individually, large-batch training, combining cyclical rates with MCMC sampling, and averaging whole regions using the curves from Garipov's paper. 76 00:15:59,029 --> 00:16:20,754 [Hal Turing] Then here's where I land. Averaging high-learning-rate SGD iterates gives a better single model than the paper's fixed-schedule baseline, and it lands close to an FGE ensemble in prediction space. Whether that comes from wider optima, or from untuned baselines and extra budget, these experiments don't settle. Thanks for listening. 77 00:16:20,754 --> 00:16:22,329 [Dr. Ada Shannon] Thanks, everyone.