A library which combines Coin-Betting algorithms and test functions for optimization algorithms.
Install it with pip install optimal_pytorch
.
A minimal example is shown below
import torch
from optimal_pytorch.coin_betting.torch import Cocob
loss_f = lambda x: x**2
y = torch.tensor([20.0], requires_grad=True)
optimizer = Cocob([y])
iterations = 50
for step in range(iterations):
optimizer.zero_grad()
loss = loss_f(y)
loss.backward()
optimizer.step()
print(y)