techlist.io

Stochastic Gradient Descent

4 posts

OpenAI2018-03-063 min readCurated summary

Reptile: A scalable meta-learning algorithm

# Reptile: A Simple, Scalable Meta-Learning Algorithm Reptile is a meta-learning algorithm that finds a neural network initialization from which new tasks can be learned quickly from few examples. It works by repeatedly sampling a task, running standard SGD on it, and moving the initial parameters toward the adapted result. Mathematically it resembles first-order MAML, but it needs only black-box access to an optimizer such as SGD or Adam, and it achieves similar performance with lower computational cost. ## Meta-Learning and the Few-Shot Setting - Meta-learning takes a distribution of tasks, each a learning problem, and produces a learner that generalizes from a small number of examples. - A well-studied case is few-shot classification, where the learner sees only 1–5 examples per class before classifying new inputs. ## How Reptile Differs from MAML - MAML unrolls and differentiates through the gradient descent computation graph, which requires second derivatives. - Reptile runs ordinary SGD on each task and never builds a computation graph or computes second derivatives, so it uses less computation and memory. - The update moves the initialization toward the task-adapted parameters. Treating that difference as a gradient allows plugging it into a more sophisticated optimizer such as Adam. ## Why It Works - With one SGD step per task (k=1), the method reduces to joint training on the mixture of all tasks. Joint training learns little when zero-shot learning is impossible, such as when output labels are randomly permuted. - Reptile requires multiple steps (k>1), where the update depends on higher-order derivatives of the loss. - A Taylor-series analysis shows that the Reptile update maximizes the inner product between gradients from different minibatches of the same task, which corresponds to better generalization. The authors suggest this may also help explain the generalization of SGD outside meta-learning. - Reptile and MAML produce similar updates, containing the same two terms with different weights. ## Experimental Results - On the Omniglot and Mini-ImageNet few-shot classification benchmarks, Reptile and MAML perform similarly. - Reptile converges faster because its update has lower variance. - Summing different combinations of SGD minibatch gradients yields a family of algorithms. Using only the second gradient corresponds to first-order MAML. Including more gradients speeds learning through variance reduction, and using only the first gradient makes no progress, as the analysis predicts. ## Implementations - The official implementation uses TensorFlow and includes code to replicate the Omniglot and Mini-ImageNet experiments. - A smaller JavaScript implementation fine-tunes a TensorFlow-pretrained model and powers the interactive 1-shot classification demo. - A minimal PyTorch example performs few-shot regression on random sine waves from 10 (x, y) pairs. ## Relationship to Prior Work The authors note that first-order MAML and Reptile are more closely related than the names suggest. They take different perspectives but compute similar updates. Reptile's contribution builds on Shortest Descent and on avoiding second derivatives in meta-learning. The post's first paragraph was updated to reflect this.

OpenAI2017-12-032 min readCurated summary

Learning sparse neural networks through L₀ regularization

This paper proposes a practical way to apply L₀ norm regularization to neural networks, pruning the network during training by pushing weights to become exactly zero. The authors argue this can speed up training and inference and improve generalization. Because the L₀ norm is non-differentiable, they make it trainable by attaching stochastic gates to the weights and optimizing the gate distributions jointly with the network parameters using standard stochastic gradient descent. ## Why L₀ Regularization Is Hard to Apply - Exact sparsity is attractive because it corresponds to model selection, and AIC and BIC are special cases of L₀ regularization. - The L₀ norm of the weights is non-differentiable, so it cannot be added directly to the objective function as a regularization term. ## Stochastic Gates as a Workaround - A collection of non-negative stochastic gates determines which weights are set to zero. - For certain gate distributions, the expected L₀ norm of the gated weights is differentiable with respect to the distribution parameters, which makes it usable in gradient-based training. - The gate distribution is a "hard concrete" distribution, built by stretching a binary concrete distribution and passing its samples through a hard-sigmoid. ## Benefits of the Approach - Model structure can be learned with ordinary stochastic gradient descent, without a separate pruning stage. - Conditional computation can be handled in a principled way, since gated-off weights need not be computed. - The authors report experiments showing the effectiveness of both the approach and the regularizer, though the excerpt does not include their specific results.

OpenAI2016-02-241 min readCurated summary

Weight normalization: A simple reparameterization to accelerate training of deep neural networks

Weight normalization is a reparameterization of neural network weight vectors that separates each vector's length from its direction. This improves the conditioning of the optimization problem and speeds up stochastic gradient descent. Unlike batch normalization, it creates no dependencies between examples in a minibatch, so it works for recurrent models, reinforcement learning, and generative models. The authors report that it captures much of batch normalization's speedup at lower computational cost. ### The Reparameterization - Each weight vector is split into a length component and a direction component. - Decoupling these two components improves conditioning of the optimization problem. ### Advantages over Batch Normalization - It is inspired by batch normalization but is simpler to implement. - It does not depend on minibatch statistics, so each example is processed independently. - It suits recurrent architectures like LSTMs, where batch normalization is less well suited. - It suits noise-sensitive settings such as deep reinforcement learning and generative modelling. - Its computational overhead is lower, so more optimization steps fit in the same training time. ### Demonstrated Applications - Supervised image recognition - Generative modelling - Deep reinforcement learning