Skip to content

Commit

Permalink
Product manifold (#109)
Browse files Browse the repository at this point in the history
* draft product manifold class

* add initial progress on some methods

* test slicing

* add projections

* draft other methods

* add tests and fix broadcasting bugs

* add typehints and make sure there are no more broadcasting problems

* fix lint issue

* fix lint issues

* fix dist

* add scaling utils

* fix typo

* fix inner product result

* add scalings for poincare

* scaling rescaling test

* fix dir method

* empty tensor fix

* add a bit more tests for product manifold

* fix typo

* some nitpicka

* add random methods and device/dtype consistency when __init__

* rest random

* remove annotation

* fix lint errors

* dist test

* make scaled implementation much cleaner

* add comments

* fix docstring

* add restricted methods

* black

* better name

* fix logmap

* fix logmap

* fix logmap

* add component inner method

* change doc

* fix doc

* add origin

* update changelog

* try o avoid warnings in multigpu env with origin

* add more docs for Scaling Info

* add docs

* fix doc

* method directive is not valif

* origin docs

* fix lineskip

* update readme

* fix attributes

* improve component inner for euclidean manifold

* fix broadcasting

* fix typo

* fix signature

* black

* update black
  • Loading branch information
ferrine committed Oct 30, 2019
1 parent 9c05e6a commit 1cefe59
Show file tree
Hide file tree
Showing 23 changed files with 1,609 additions and 159 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ New Features
* Added Poincare Ball model (#45)
* Poincare Ball manifold has now new methods (#78)
* Added ``ndim`` argument to ``Euclidean`` manifold

* Added ``Product`` manifold (#109)
* Added ``Scaled`` manifold (#109)
* Unified ``random`` for manifolds (#109) so it can be used in product manifold
* Added ``origin`` for manifolds (#109), it is useful for embeddings

Maintenance
-----------
Expand Down
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ points on a certain manifold
projected, they are assumed to be already projected.
- ``.retr(u)`` – retraction map following vector ``u``
- ``.expmap(u)`` – exponential map following vector ``u`` (if expmap is not available in closed form, best approximation is used)
- ``.transp(v, u, *more)`` – transport vector ``v`` (and possibly
more vectors) with direction ``u``
- ``.retr_transp(v, u, *more)`` – transport ``self``, vector ``v``
- ``.transp(v, u)`` – transport vector ``v`` with direction ``u``
- ``.retr_transp(v, u)`` – transport ``self``, vector ``v``
(and possibly more vectors) with direction ``u``
(returns are plain tensors)

Expand All @@ -71,6 +70,8 @@ Manifolds
``A in R^{n x p} : A^t A=I``, ``n >= p``
- ``geoopt.Sphere`` - Sphere manifold ``||x||=1``
- ``geoopt.PoincareBall`` - Poincare ball model (`wiki <https://en.wikipedia.org/wiki/Poincar%C3%A9_disk_model>`_)
- ``geoopt.ProductManifold`` - Product manifold constructor
- ``geoopt.Scaled`` - Scaled version of the manifold. Similar to `Learning Mixed-Curvature Representations in Product Spaces <https://openreview.net/forum?id=HJxeWnCcF7>`_ if combined with ``ProductManifold``


All manifolds implement methods necessary to manipulate tensors on manifolds and
Expand Down
12 changes: 12 additions & 0 deletions docs/devguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ The common base class for all manifolds is :class:`geoopt.manifolds.base.Manifol
:private-members:
:members:
:noindex:


.. autoclass:: geoopt.manifolds.base.ScalingStorage
:private-members:
:members:
:noindex:


.. autoclass:: geoopt.manifolds.base.ScalingInfo
:private-members:
:members:
:noindex:
2 changes: 1 addition & 1 deletion docs/manifolds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Manifolds
All manifolds share same API. Some manifols may have several implementations of retraction operation, every implementation has a corresponding class.

.. automodule:: geoopt.manifolds
:members: Euclidean, Stiefel, CanonicalStiefel, EuclideanStiefel, EuclideanStiefelExact, Sphere, SphereExact, PoincareBall, PoincareBallExact
:members: Euclidean, Stiefel, CanonicalStiefel, EuclideanStiefel, EuclideanStiefelExact, Sphere, SphereExact, PoincareBall, PoincareBallExact, Scaled, ProductManifold


2 changes: 2 additions & 0 deletions geoopt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
SphereExact,
PoincareBall,
PoincareBallExact,
ProductManifold,
Scaled,
)

__version__ = "0.0.1"
3 changes: 3 additions & 0 deletions geoopt/manifolds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
from .stiefel import Stiefel, EuclideanStiefel, CanonicalStiefel, EuclideanStiefelExact
from .sphere import Sphere, SphereExact
from .poincare import PoincareBall, PoincareBallExact
from .product import ProductManifold
from . import poincare
from . import scaled
from .scaled import Scaled

0 comments on commit 1cefe59

Please sign in to comment.