Views
No views yet
VeLO is a learned optimizer meta-trained on thousands of diverse machine learning tasks. It corresponds to the VeLO (Versatile Learned Optimizer) from VeLO: Training Versatile Learned Optimizers by Scaling Up.| Field | Value |
|---|---|
| Meta-training distribution | Thousands of ML tasks including MLPs, CNNs, ResNets, VAEs, classification, regression |
| Number of meta-training TPU-months | ~4000 |
| Target inner problem length | 150000 (max) |
| Gradient estimator | Evolution Strategies |
| Architecture | LSTM-based hypernetwork |
1git clone https://github.com/Belilovsky-Lab/pylo
2cd pylo
3pip install .
4python setup.py install --cuda1
2from pylo.optim import VeLO
3optimizer = VeLO(model.parameters(), lr=1.0 , num_steps=150_000)1import torch
2import torch.nn as nn
3import torch.optim as optim
4from torchvision import datasets, transforms
5from torch.utils.data import DataLoader
6
7# Model
8class MLP(nn.Module):
9 def __init__(self):
10 super().__init__()
11 self.net = nn.Sequential(
12 nn.Flatten(),
13 nn.Linear(28 * 28, 128),
14 nn.ReLU(),
15 nn.Linear(128, 10)
16 )
17 def forward(self, x):
18 return self.net(x)
19
20model = MLP().to(device)
21
22#########################
23Setup Learned Optimizer
24#########################
25optimizer = VeLO(model.parameters(), lr=1.0 , num_steps=150_000)
26
27# Device
28device = torch.device('cuda')
29
30# Data
31transform = transforms.ToTensor()
32train_loader = DataLoader(datasets.MNIST(root='./data', train=True, download=True, transform=transform),
33 batch_size=64, shuffle=True)
34
35criterion = nn.CrossEntropyLoss()
36# Training loop
37for epoch in range(1): # Just 1 epoch for simplicity
38 for x, y in train_loader:
39 x, y = x.to(device), y.to(device)
40 optimizer.zero_grad()
41 loss = criterion(model(x), y)
42 loss.backward()
43 optimizer.step(loss)
44
45print("Done!") |1@article{metz2022velo,
2 title={{VeLO}: Training Versatile Learned Optimizers by Scaling Up},
3 author={Luke Metz and James Harrison and C. Daniel Freeman and Amil Merchant and Lucas Beyer and James Bradbury and Naman Agrawal and Ben Poole and Igor Mordatch and Adam Roberts and Jascha Sohl-Dickstein},
4 journal={arXiv preprint arXiv:2211.09760},
5 year={2022},
6 url={https://arxiv.org/abs/2211.09760}
7}