Manifold aware pytorch.optim
.
Unofficial implementation for “Riemannian Adaptive Optimization Methods” ICLR2019 and more.
Make sure you have pytorch>=1.1.0 installed
There are two ways to install geoopt:
- GitHub (preferred so far) due to active development
pip install git+https://github.com/geoopt/geoopt.git
- pypi (this might be significantly behind master branch)
pip install geoopt
The preferred way to install geoopt will change once stable project stage is achieved. Now, pypi is behind master as we actively develop and implement new features.
Work is in progress but you can already use this. Note that API might change in future releases.
geoopt.ManifoldTensor
– just as torch.Tensor with additionalmanifold
keyword argument.geoopt.ManifoldParameter
– same as above, recognized intorch.nn.Module.parameters
as correctly subclassed.
All above containers have special methods to work with them as with points on a certain manifold
.proj_()
– inplace projection on the manifold..proju(u)
– project vectoru
on the tangent space. You need to project all vectors for all methods below..egrad2rgrad(u)
– project gradientu
on Riemannian manifold.inner(u, v=None)
– inner product at this point for two tangent vectors at this point. The passed vectors are not projected, they are assumed to be already projected..retr(u)
– retraction map following vectoru
.expmap(u)
– exponential map following vectoru
(if expmap is not available in closed form, best approximation is used).transp(v, u, *more)
– transport vectorv
(and possibly more vectors) with directionu
.retr_transp(v, u, *more)
– transportself
, vectorv
(and possibly more vectors) with directionu
(returns are plain tensors)
geoopt.Euclidean
– unconstrained manifold inR
with Euclidean metricgeoopt.Stiefel
– Stiefel manifold on matricesA in R^{n x p} : A^t A=I
,n >= p
geoopt.Sphere
- Sphere manifold||x||=1
geoopt.PoincareBall
- Poincare ball model (wiki)
All manifolds implement methods necessary to manipulate tensors on manifolds and tangent vectors to be used in general purpose. See more in documentation.
geoopt.optim.RiemannianSGD
– a subclass oftorch.optim.SGD
with the same APIgeoopt.optim.RiemannianAdam
– a subclass oftorch.optim.Adam
geoopt.samplers.RSGLD
– Riemannian Stochastic Gradient Langevin Dynamicsgeoopt.samplers.RHMC
– Riemannian Hamiltonian Monte-Carlogeoopt.samplers.SGRHMC
– Stochastic Gradient Riemannian Hamiltonian Monte-Carlo
If you find this project useful in your research, please kindly add this bibtex entry in references.
@misc{geoopt, author = {Max Kochurov and Sergey Kozlukov and Rasul Karimov and Viktor Yanush}, title = {Geoopt: Adaptive Riemannian optimization in PyTorch}, year = {2019}, publisher = {GitHub}, journal = {GitHub repository}, howpublished = {\url{https://github.com/geoopt/geoopt}}, }