Upgrading from 2.x
In Pymanopt 3.0, backends provide the arithmetic of manifolds
in addition to derivatives, so manifolds compute with the backend’s arrays
instead of NumPy arrays.
The backend decorators and the APIs of pymanopt.core.problem.Problem
and the optimizers are unchanged.
The
pymanopt.autodiffpackage was removed. TheFunctionclass moved topymanopt.function, and backends topymanopt.backends.Python. Pymanopt requires Python 3.11 or later.
Results are backend arrays. Optimizers no longer convert points to NumPy arrays, e.g.
result.pointis atorch.Tensorwith PyTorch.point = result.point # 2.x point = result.point.numpy() # 3.0
Inputs are backend arrays. An
initial_pointpassed to an optimizer must be an array of the backend, and so should constants used in the cost function.Manifolds used outside of a problem need a backend. This affects, among others,
random_pointandpymanopt.tools.diagnostics.check_retraction().manifold = Sphere(3) # 2.x manifold = Sphere(3, backend=NumpyBackend()) # 3.0
Complex manifolds expect a complex data type. Otherwise a warning is emitted.
@pymanopt.function.jax(manifold, dtype=JaxBackend.DEFAULT_COMPLEX_DTYPE()) def cost(point): ...
Custom manifolds. Replace NumPy calls by calls to
self.backend, e.g.np.cosbyself.backend.cos, and accept abackendargument that is forwarded to the base class constructor.Custom backends. Backends now implement the interface of
pymanopt.backends.backend.Backend, which adds data type handling and the numerical functions used by manifolds. Theis_availableandprepare_functionmethods were removed.backend_decorator_factory(backend_cls)was replaced bypymanopt.function.decorator_factory(), which takes the module and class names of the backend.