piazzi

Deterministic PyTorch solvers for nonlinear fitting problems.

piazzi targets fitting problems such as pose or camera registration, curve fitting and bundle adjustment, where every objective evaluation is expensive (rendering, for example) and you want each evaluation to count. torch.optim targets stochastic training instead; piazzi targets full-batch, curvature-aware fitting.

Named after Giuseppe Piazzi, who discovered the dwarf planet Ceres in 1801. Gauss recovered Ceres from Piazzi’s observations by inventing least squares.

import torch
import piazzi

t = torch.linspace(0, 4, 40)
y = 2.5 * torch.exp(-1.3 * t)
y[::10] += 2.0  # outliers

res = piazzi.least_squares(
    lambda th: th[0] * torch.exp(-th[1] * t) - y, torch.tensor([1.0, 0.5]), loss="cauchy", f_scale=0.1
)
print(res.x, res.message)  # tensor([2.5026, 1.3005]) step below step_tol
Getting started

Install piazzi, run a first fit, and read the result.

Getting started
User guide

Solvers, robust losses, manifolds, sparse problems, devices and backends.

User guide
Examples

Executed notebooks: robust regression, Rosenbrock, bundle adjustment.

Examples
API reference

Every public function and class.

API reference

Status: alpha (pre-release on PyPI), and the API may change.