liveBook · Manning

Amortized optimization

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

A technique that learns to predict solutions to repeated optimization problems so computation is shifted from repeated solving to training and inference.

Amortized optimization, also called learning to optimize, trains a machine-learning model to predict optimal or near-optimal solutions for repeated optimization problems. It shifts computation from repeatedly solving each instance toward training and fast inference. section 11.6

A supervised-learning workflow can:

  • Represent each optimization problem through its parameters. section 11.6
  • Train a model to map those parameters to a candidate solution. section 11.6

Optimizing a function on a sphere

For functions defined over the earth or another spherical space, the model predicts a point on the unit 2-sphere. Celestial-to-Euclidean conversion represents right ascension and declination as three-dimensional coordinates; the trained model then produces candidate extreme points. section 11.6

Listing 11.3 Solving a function optimization problem using supervised learning
import torch
from torch import nn
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
  
def celestial_to_euclidean(ra, dec):             #1
    x = np.cos(dec)*np.cos(ra)
    y = np.cos(dec)*np.sin(ra)
    z = np.sin(dec)
    return x, y, z
  
def euclidean_to_celestial(x, y, z):             #2
    sindec = z
    cosdec = (x*x + y*y).sqrt()
    sinra = y / cosdec
    cosra = x / cosdec
    ra = torch.atan2(sinra, cosra)
    dec = torch.atan2(sindec, cosdec)
    return ra, dec
  
def sphere_dist(x,y):                            #3
    if x.ndim == 1:
        x = x.unsqueeze(0)
    if y.ndim == 1:
        y = y.unsqueeze(0)
    assert x.ndim == y.ndim == 2
    inner = (x*y).sum(-1)
    return torch.arccos(inner)

Inspect the conversion functions and spherical-distance calculation used to represent and compare candidate solutions. section 11.6

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Defines the mapping and demonstrates supervised training, but does not detail guarantees of optimality or broader solver comparisons.
Examples
Uses extreme-value search on spherical functions, celestial-coordinate conversion, neural networks, and Adam-based training.
What you can do after
Build it from scratch with PyTorch by parameterizing candidate functions, defining a neural predictor, and training it against objective values.
How it connects
Ties supervised learning to machine learning, objective functions, parameterized optimization, and spherical coordinate representations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.