tensorflow-riemopt 0.1.2__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {tensorflow-riemopt-0.1.2/tensorflow_riemopt.egg-info → tensorflow_riemopt-0.3.0}/PKG-INFO +20 -6
  2. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/README.md +2 -0
  3. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/setup.py +7 -7
  4. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/cholesky.py +1 -0
  5. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/euclidean.py +1 -0
  6. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/grassmannian.py +1 -0
  7. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/hyperboloid.py +2 -1
  8. tensorflow_riemopt-0.3.0/tensorflow_riemopt/manifolds/mainfold_test.py +59 -0
  9. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/manifold.py +1 -1
  10. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/poincare.py +10 -9
  11. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/product.py +1 -0
  12. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/special_orthogonal.py +1 -0
  13. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/symmetric_positive.py +1 -0
  14. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/test_invariants.py +1 -0
  15. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/constrained_rmsprop.py +15 -15
  16. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/constrained_rmsprop_test.py +8 -6
  17. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/riemannian_adam.py +16 -16
  18. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/riemannian_adam_test.py +4 -2
  19. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/riemannian_gradient_descent.py +22 -17
  20. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/riemannian_gradient_descent_test.py +6 -4
  21. tensorflow_riemopt-0.3.0/tensorflow_riemopt/optimizers/test_optimizers_manifold.py +47 -0
  22. tensorflow_riemopt-0.3.0/tensorflow_riemopt/variable.py +20 -0
  23. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0/tensorflow_riemopt.egg-info}/PKG-INFO +20 -6
  24. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt.egg-info/SOURCES.txt +3 -1
  25. tensorflow_riemopt-0.3.0/tensorflow_riemopt.egg-info/requires.txt +1 -0
  26. tensorflow-riemopt-0.1.2/tensorflow_riemopt/variable.py +0 -20
  27. tensorflow-riemopt-0.1.2/tensorflow_riemopt.egg-info/requires.txt +0 -2
  28. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/LICENSE +0 -0
  29. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/setup.cfg +0 -0
  30. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/__init__.py +0 -0
  31. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/layers/__init__.py +0 -0
  32. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/layers/embeddings.py +0 -0
  33. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/layers/embeddings_test.py +0 -0
  34. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/__init__.py +0 -0
  35. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/approximate_mixin.py +0 -0
  36. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/approximate_mixin_test.py +0 -0
  37. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/cholesky_test.py +0 -0
  38. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/euclidean_test.py +0 -0
  39. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/grassmannian_test.py +0 -0
  40. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/hyperboloid_test.py +0 -0
  41. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/poincare_test.py +0 -0
  42. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/product_test.py +0 -0
  43. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/special_orthogonal_test.py +0 -0
  44. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/sphere.py +0 -0
  45. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/sphere_test.py +0 -0
  46. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/stiefel.py +0 -0
  47. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/stiefel_test.py +0 -0
  48. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/symmetric_positive_test.py +0 -0
  49. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/manifolds/utils.py +0 -0
  50. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/optimizers/__init__.py +0 -0
  51. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt/variable_test.py +0 -0
  52. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt.egg-info/dependency_links.txt +0 -0
  53. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt.egg-info/top_level.txt +0 -0
  54. {tensorflow-riemopt-0.1.2 → tensorflow_riemopt-0.3.0}/tensorflow_riemopt.egg-info/zip-safe +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tensorflow-riemopt
3
- Version: 0.1.2
3
+ Version: 0.3.0
4
4
  Summary: a library for optimization on Riemannian manifolds
5
5
  Home-page: https://github.com/master/tensorflow-riemopt
6
6
  Author: Oleg Smirnov
@@ -10,22 +10,35 @@ Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Intended Audience :: Science/Research
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.6
14
- Classifier: Programming Language :: Python :: 3.7
15
- Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Topic :: Scientific/Engineering :: Mathematics
17
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Classifier: Topic :: Software Development :: Libraries
19
19
  Classifier: Operating System :: OS Independent
20
- Requires-Python: >=3.6.0
20
+ Requires-Python: >=3.10.0
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
+ Requires-Dist: tensorflow
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license-file
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
23
35
 
24
36
  # TensorFlow RiemOpt
25
37
 
26
38
  [![PyPI](https://img.shields.io/pypi/v/tensorflow-riemopt.svg)](https://pypi.org/project/tensorflow-riemopt/)
27
39
  [![arXiv](https://img.shields.io/badge/arXiv-2105.13921-b31b1b.svg)](https://arxiv.org/abs/2105.13921)
28
40
  [![Build Status](https://github.com/master/tensorflow-riemopt/actions/workflows/build.yml/badge.svg)](https://github.com/master/tensorflow-riemopt/actions)
41
+ [![Documentation Status](https://readthedocs.org/projects/tensorflow-riemopt/badge/?version=latest)](https://tensorflow-riemopt.readthedocs.io)
29
42
  [![Coverage Status](https://coveralls.io/repos/github/master/tensorflow-riemopt/badge.svg)](https://coveralls.io/github/master/tensorflow-riemopt)
30
43
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
31
44
  [![License](https://img.shields.io/:license-mit-blue.svg)](https://badges.mit-license.org)
@@ -103,6 +116,7 @@ optimizers for sparse and dense updates in both Eager and Graph modes.
103
116
 
104
117
  ## Examples
105
118
 
119
+ - [ANTHEM](https://github.com/amazon-science/hyperbolic-embeddings/tree/main/product_matching) - Choudhary, Nurendra, Nikhil Rao, Sumeet Katariya, Karthik Subbian, and Chandan K. Reddy. "ANTHEM: Attentive Hyperbolic Entity Model for Product Search." In Proceedings of the Fifteenth ACM International Conference on Web Search and Data Mining, 2022.
106
120
  - [SPDNet](examples/spdnet/) - Huang, Zhiwu, and Luc Van Gool. "A Riemannian network for SPD matrix learning." Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence. AAAI Press, 2017.
107
121
  - [LieNet](examples/lienet/) - Huang, Zhiwu, et al. "Deep learning on Lie groups for skeleton-based action recognition." Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.
108
122
  - [GrNet](examples/grnet/) - Huang, Zhiwu, Jiqing Wu, and Luc Van Gool. "Building Deep Networks on Grassmann Manifolds." AAAI. AAAI Press, 2018.
@@ -3,6 +3,7 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/tensorflow-riemopt.svg)](https://pypi.org/project/tensorflow-riemopt/)
4
4
  [![arXiv](https://img.shields.io/badge/arXiv-2105.13921-b31b1b.svg)](https://arxiv.org/abs/2105.13921)
5
5
  [![Build Status](https://github.com/master/tensorflow-riemopt/actions/workflows/build.yml/badge.svg)](https://github.com/master/tensorflow-riemopt/actions)
6
+ [![Documentation Status](https://readthedocs.org/projects/tensorflow-riemopt/badge/?version=latest)](https://tensorflow-riemopt.readthedocs.io)
6
7
  [![Coverage Status](https://coveralls.io/repos/github/master/tensorflow-riemopt/badge.svg)](https://coveralls.io/github/master/tensorflow-riemopt)
7
8
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
8
9
  [![License](https://img.shields.io/:license-mit-blue.svg)](https://badges.mit-license.org)
@@ -80,6 +81,7 @@ optimizers for sparse and dense updates in both Eager and Graph modes.
80
81
 
81
82
  ## Examples
82
83
 
84
+ - [ANTHEM](https://github.com/amazon-science/hyperbolic-embeddings/tree/main/product_matching) - Choudhary, Nurendra, Nikhil Rao, Sumeet Katariya, Karthik Subbian, and Chandan K. Reddy. "ANTHEM: Attentive Hyperbolic Entity Model for Product Search." In Proceedings of the Fifteenth ACM International Conference on Web Search and Data Mining, 2022.
83
85
  - [SPDNet](examples/spdnet/) - Huang, Zhiwu, and Luc Van Gool. "A Riemannian network for SPD matrix learning." Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence. AAAI Press, 2017.
84
86
  - [LieNet](examples/lienet/) - Huang, Zhiwu, et al. "Deep learning on Lie groups for skeleton-based action recognition." Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.
85
87
  - [GrNet](examples/grnet/) - Huang, Zhiwu, Jiqing Wu, and Luc Van Gool. "Building Deep Networks on Grassmann Manifolds." AAAI. AAAI Press, 2018.
@@ -3,15 +3,15 @@ from setuptools import setup, find_packages
3
3
 
4
4
  setup(
5
5
  name="tensorflow-riemopt",
6
- version="0.1.2",
6
+ version="0.3.0",
7
7
  description="a library for optimization on Riemannian manifolds",
8
- long_description=open("README.md", "r").read(),
8
+ long_description=open("README.md").read(),
9
9
  long_description_content_type="text/markdown",
10
10
  author="Oleg Smirnov",
11
11
  author_email="oleg.smirnov@gmail.com",
12
12
  packages=find_packages(),
13
- install_requires=["tensorflow==2.6.3", "protobuf==3.19.6"],
14
- python_requires=">=3.6.0",
13
+ install_requires=["tensorflow"],
14
+ python_requires=">=3.10.0",
15
15
  url="https://github.com/master/tensorflow-riemopt",
16
16
  zip_safe=True,
17
17
  classifiers=[
@@ -19,9 +19,9 @@ setup(
19
19
  "Intended Audience :: Science/Research",
20
20
  "License :: OSI Approved :: MIT License",
21
21
  "Programming Language :: Python :: 3",
22
- "Programming Language :: Python :: 3.6",
23
- "Programming Language :: Python :: 3.7",
24
- "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
25
  "Topic :: Scientific/Engineering :: Mathematics",
26
26
  "Topic :: Software Development :: Libraries :: Python Modules",
27
27
  "Topic :: Software Development :: Libraries",
@@ -1,4 +1,5 @@
1
1
  """Manifold of the Cholesky space."""
2
+
2
3
  import tensorflow as tf
3
4
 
4
5
  from tensorflow_riemopt.manifolds.manifold import Manifold
@@ -1,4 +1,5 @@
1
1
  """Manifold of the Euclidean space."""
2
+
2
3
  import tensorflow as tf
3
4
 
4
5
  from tensorflow_riemopt.manifolds.manifold import Manifold
@@ -1,4 +1,5 @@
1
1
  """Manifold of linear subspaces of a vector space."""
2
+
2
3
  import tensorflow as tf
3
4
 
4
5
  from tensorflow_riemopt.manifolds.manifold import Manifold
@@ -1,4 +1,5 @@
1
1
  """The Lorentz model."""
2
+
2
3
  import tensorflow as tf
3
4
 
4
5
  from tensorflow_riemopt.manifolds.manifold import Manifold
@@ -24,7 +25,7 @@ class Hyperboloid(Manifold):
24
25
  super().__init__()
25
26
 
26
27
  def __repr__(self):
27
- return "{0} (k={1}, ndims={2}) manifold".format(
28
+ return "{} (k={}, ndims={}) manifold".format(
28
29
  self.name, self.k, self.ndims
29
30
  )
30
31
 
@@ -0,0 +1,59 @@
1
+ import tensorflow as tf
2
+ from tensorflow_riemopt.manifolds.manifold import Manifold
3
+
4
+
5
+ class DummyManifold2(Manifold):
6
+ """Minimal manifold to exercise default pairmean and random."""
7
+
8
+ name = "Dummy2"
9
+ ndims = 0
10
+
11
+ def _check_point_on_manifold(self, x, atol, rtol):
12
+ return tf.constant(True)
13
+
14
+ def _check_vector_on_tangent(self, x, u, atol, rtol):
15
+ return tf.constant(True)
16
+
17
+ def log(self, x, y):
18
+ return y - x
19
+
20
+ def exp(self, x, u):
21
+ return x + u
22
+
23
+ def proju(self, x, u):
24
+ return u
25
+
26
+ def projx(self, x):
27
+ return x
28
+
29
+ def dist(self, x, y, keepdims=False):
30
+ return tf.zeros_like(x)
31
+
32
+ def inner(self, x, u, v, keepdims=False):
33
+ return tf.zeros_like(u[..., :1])
34
+
35
+ def retr(self, x, u):
36
+ return self.exp(x, u)
37
+
38
+ def geodesic(self, x, u, t):
39
+ return x + t * u
40
+
41
+ def transp(self, x, y, v):
42
+ return v
43
+
44
+
45
+ def test_pairmean_default():
46
+ m = DummyManifold2()
47
+ x = tf.constant([1.0, 3.0], dtype=tf.float32)
48
+ y = tf.constant([5.0, 7.0], dtype=tf.float32)
49
+ pm = m.pairmean(x, y)
50
+ tf.debugging.assert_near(pm, (x + y) / 2.0)
51
+
52
+
53
+ def test_random_default():
54
+ m = DummyManifold2()
55
+ shape = (4, 2)
56
+ x = m.random(shape, dtype=tf.float64)
57
+ assert isinstance(x, tf.Tensor)
58
+ assert x.shape.as_list() == list(shape)
59
+ assert x.dtype == tf.float64
@@ -8,7 +8,7 @@ class Manifold(metaclass=abc.ABCMeta):
8
8
 
9
9
  def __repr__(self):
10
10
  """Returns a string representation of the particular manifold."""
11
- return "{0} (ndims={1}) manifold".format(self.name, self.ndims)
11
+ return "{} (ndims={}) manifold".format(self.name, self.ndims)
12
12
 
13
13
  def check_shape(self, shape_or_tensor):
14
14
  """Check if given shape is compatible with the manifold."""
@@ -1,4 +1,5 @@
1
1
  """The Poincaré ball model."""
2
+
2
3
  import tensorflow as tf
3
4
 
4
5
  from tensorflow_riemopt.manifolds.manifold import Manifold
@@ -31,7 +32,7 @@ class Poincare(Manifold):
31
32
  super().__init__()
32
33
 
33
34
  def __repr__(self):
34
- return "{0} (k={1}, ndims={2}) manifold".format(
35
+ return "{} (k={}, ndims={}) manifold".format(
35
36
  self.name, self.k, self.ndims
36
37
  )
37
38
 
@@ -45,10 +46,10 @@ class Poincare(Manifold):
45
46
 
46
47
  def _mobius_add(self, x, y):
47
48
  """Compute the Möbius addition of :math:`x` and :math:`y` in
48
- :math:`\mathcal{D}^{n}_{k}`
49
+ :math:`\\mathcal{D}^{n}_{k}`
49
50
 
50
- :math:`x \oplus y = \frac{(1 + 2k\langle x, y\rangle + k||y||^2)x + (1
51
- - k||x||^2)y}{1 + 2k\langle x,y\rangle + k^2||x||^2||y||^2}`
51
+ :math:`x \\oplus y = \frac{(1 + 2k\\langle x, y\rangle + k||y||^2)x + (1
52
+ - k||x||^2)y}{1 + 2k\\langle x,y\rangle + k^2||x||^2||y||^2}`
52
53
  """
53
54
  x_2 = tf.reduce_sum(tf.math.square(x), axis=-1, keepdims=True)
54
55
  y_2 = tf.reduce_sum(tf.math.square(y), axis=-1, keepdims=True)
@@ -59,11 +60,11 @@ class Poincare(Manifold):
59
60
  )
60
61
 
61
62
  def _mobius_scal_mul(self, x, r):
62
- """Compute the Möbius scalar multiplication of :math:`x \in
63
- \mathcal{D}^{n}_{k} \ {0}` by :math:`r`
63
+ """Compute the Möbius scalar multiplication of :math:`x \\in
64
+ \\mathcal{D}^{n}_{k} \\ {0}` by :math:`r`
64
65
 
65
- :math:`x \otimes r = (1/\sqrt{k})\tanh(r
66
- \atanh(\sqrt{k}||x||))\frac{x}{||x||}`
66
+ :math:`x \\otimes r = (1/\\sqrt{k})\tanh(r
67
+ \atanh(\\sqrt{k}||x||))\frac{x}{||x||}`
67
68
 
68
69
  """
69
70
  sqrt_k = tf.math.sqrt(tf.cast(self.k, x.dtype))
@@ -73,7 +74,7 @@ class Poincare(Manifold):
73
74
  return (1 / sqrt_k) * tf.math.tanh(r * tf.math.atanh(tan)) * x / norm_x
74
75
 
75
76
  def _gyration(self, u, v, w):
76
- """Compute the gyration of :math:`u`, :math:`v`, :math:`w`:
77
+ r"""Compute the gyration of :math:`u`, :math:`v`, :math:`w`:
77
78
 
78
79
  :math:`\operatorname{gyr}[u, v]w =
79
80
  \ominus (u \oplus_\kappa v) \oplus (u \oplus_\kappa (v \oplus_\kappa w))`
@@ -1,4 +1,5 @@
1
1
  """Cartesian product of manifolds."""
2
+
2
3
  import tensorflow as tf
3
4
  from functools import reduce
4
5
  from operator import mul
@@ -1,4 +1,5 @@
1
1
  """Manifold of rotation matrices."""
2
+
2
3
  import tensorflow as tf
3
4
 
4
5
  from tensorflow_riemopt.manifolds.manifold import Manifold
@@ -1,4 +1,5 @@
1
1
  """Manifolds of symmetric positive definite matrices."""
2
+
2
3
  import warnings
3
4
 
4
5
  import tensorflow as tf
@@ -1,4 +1,5 @@
1
1
  """Manifold test invariants."""
2
+
2
3
  import tensorflow as tf
3
4
  import numpy as np
4
5
 
@@ -4,6 +4,7 @@ Kumar Roy, Soumava, Zakaria Mhammedi, and Mehrtash Harandi. "Geometry aware
4
4
  constrained optimization techniques for deep learning." Proceedings of the
5
5
  IEEE Conference on Computer Vision and Pattern Recognition. 2018.
6
6
  """
7
+
7
8
  import numpy as np
8
9
 
9
10
  from tensorflow.python.eager import def_function
@@ -14,8 +15,9 @@ from tensorflow.python.ops import array_ops
14
15
  from tensorflow.python.ops import control_flow_ops
15
16
  from tensorflow.python.ops import math_ops
16
17
  from tensorflow.python.ops import state_ops
17
- from tensorflow.python.training import gen_training_ops
18
- from keras.optimizer_v2.optimizer_v2 import OptimizerV2
18
+ from tensorflow.python.ops import gen_training_ops
19
+ from tensorflow.python.framework.indexed_slices import IndexedSlices
20
+ from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
19
21
 
20
22
  from tensorflow_riemopt.variable import get_manifold
21
23
 
@@ -66,7 +68,7 @@ class ConstrainedRMSprop(OptimizerV2):
66
68
  allow time inverse decay of learning rate. `lr` is included for backward
67
69
  compatibility, recommended to use `learning_rate` instead.
68
70
  """
69
- super(ConstrainedRMSprop, self).__init__(name, **kwargs)
71
+ super().__init__(name, **kwargs)
70
72
  self._set_hyper("learning_rate", kwargs.get("lr", learning_rate))
71
73
  self._set_hyper("decay", self._initial_decay)
72
74
  self._set_hyper("rho", rho)
@@ -83,15 +85,13 @@ class ConstrainedRMSprop(OptimizerV2):
83
85
  self.add_slot(var, "mg")
84
86
 
85
87
  def _prepare_local(self, var_device, var_dtype, apply_state):
86
- super(ConstrainedRMSprop, self)._prepare_local(
87
- var_device, var_dtype, apply_state
88
- )
88
+ super()._prepare_local(var_device, var_dtype, apply_state)
89
89
 
90
90
  rho = array_ops.identity(self._get_hyper("rho", var_dtype))
91
91
  apply_state[(var_device, var_dtype)].update(
92
92
  dict(
93
93
  neg_lr_t=-apply_state[(var_device, var_dtype)]["lr_t"],
94
- epsilon=ops.convert_to_tensor_v2(self.epsilon, var_dtype),
94
+ epsilon=ops.convert_to_tensor(self.epsilon, var_dtype),
95
95
  rho=rho,
96
96
  one_minus_rho=1.0 - rho,
97
97
  )
@@ -129,10 +129,10 @@ class ConstrainedRMSprop(OptimizerV2):
129
129
  rms.assign(manifold.transp(var, var_t, rms_t))
130
130
  if self.centered:
131
131
  mg.assign(manifold.transp(var, var_t, mg_t))
132
- var.assign(var_t)
133
-
132
+ var_update = var.assign(var_t)
134
133
  if self.stabilize is not None:
135
134
  self._stabilize(var)
135
+ return var_update
136
136
 
137
137
  @def_function.function(experimental_compile=True)
138
138
  def _resource_apply_sparse(self, grad, var, indices, apply_state=None):
@@ -171,16 +171,16 @@ class ConstrainedRMSprop(OptimizerV2):
171
171
  )
172
172
 
173
173
  rms_t_transp = manifold.transp(var_values, var_t_values, rms_t_values)
174
- rms.scatter_update(ops.IndexedSlices(rms_t_transp, indices))
174
+ rms.scatter_update(IndexedSlices(rms_t_transp, indices))
175
175
 
176
176
  if self.centered:
177
177
  mg_t_transp = manifold.transp(var_values, var_t_values, mg_t_values)
178
- mg.scatter_update(ops.IndexedSlices(mg_t_transp, indices))
179
-
180
- var.scatter_update(ops.IndexedSlices(var_t_values, indices))
178
+ mg.scatter_update(IndexedSlices(mg_t_transp, indices))
181
179
 
180
+ var_update = var.scatter_update(IndexedSlices(var_t_values, indices))
182
181
  if self.stabilize is not None:
183
182
  self._stabilize(var)
183
+ return var_update
184
184
 
185
185
  @def_function.function(experimental_compile=True)
186
186
  def _stabilize(self, var):
@@ -197,10 +197,10 @@ class ConstrainedRMSprop(OptimizerV2):
197
197
  params = self.weights
198
198
  if len(params) == len(weights) + 1:
199
199
  weights = [np.array(0)] + weights
200
- super(ConstrainedRMSprop, self).set_weights(weights)
200
+ super().set_weights(weights)
201
201
 
202
202
  def get_config(self):
203
- config = super(ConstrainedRMSprop, self).get_config()
203
+ config = super().get_config()
204
204
  config.update(
205
205
  {
206
206
  "learning_rate": self._serialize_hyperparameter(
@@ -1,4 +1,5 @@
1
1
  """Tests for RMSprop."""
2
+
2
3
  from absl.testing import parameterized
3
4
  import numpy as np
4
5
 
@@ -12,6 +13,7 @@ from tensorflow.python.ops import array_ops
12
13
  from tensorflow.python.ops import math_ops
13
14
  from tensorflow.python.ops import variables
14
15
  from tensorflow.python.platform import test
16
+ from tensorflow.python.framework.indexed_slices import IndexedSlices
15
17
 
16
18
  from tensorflow_riemopt.optimizers.constrained_rmsprop import (
17
19
  ConstrainedRMSprop,
@@ -43,13 +45,13 @@ class ConstrainedRMSpropTest(test.TestCase, parameterized.TestCase):
43
45
  var0_ref = variables.Variable(var0_np)
44
46
  var1_ref = variables.Variable(var1_np)
45
47
  grads0_np_indices = np.array([0, 2], dtype=np.int32)
46
- grads0 = ops.IndexedSlices(
48
+ grads0 = IndexedSlices(
47
49
  constant_op.constant(grads0_np[grads0_np_indices]),
48
50
  constant_op.constant(grads0_np_indices),
49
51
  constant_op.constant([3]),
50
52
  )
51
53
  grads1_np_indices = np.array([0, 2], dtype=np.int32)
52
- grads1 = ops.IndexedSlices(
54
+ grads1 = IndexedSlices(
53
55
  constant_op.constant(grads1_np[grads1_np_indices]),
54
56
  constant_op.constant(grads1_np_indices),
55
57
  constant_op.constant([3]),
@@ -139,14 +141,14 @@ class ConstrainedRMSpropTest(test.TestCase, parameterized.TestCase):
139
141
  self.assertAllCloseAccordingToType(
140
142
  self.evaluate(var0_ref),
141
143
  self.evaluate(var0),
142
- rtol=1e-4,
143
- atol=1e-4,
144
+ rtol=1e-3,
145
+ atol=1e-3,
144
146
  )
145
147
  self.assertAllCloseAccordingToType(
146
148
  self.evaluate(var1_ref),
147
149
  self.evaluate(var1),
148
- rtol=1e-4,
149
- atol=1e-4,
150
+ rtol=1e-2,
151
+ atol=1e-2,
150
152
  )
151
153
 
152
154
 
@@ -3,6 +3,7 @@
3
3
  Becigneul, Gary, and Octavian-Eugen Ganea. "Riemannian Adaptive Optimization
4
4
  Methods." International Conference on Learning Representations. 2018.
5
5
  """
6
+
6
7
  from tensorflow.python.eager import def_function
7
8
  from tensorflow.python.framework import ops
8
9
  from tensorflow.python.keras import backend_config
@@ -11,8 +12,9 @@ from tensorflow.python.ops import array_ops
11
12
  from tensorflow.python.ops import control_flow_ops
12
13
  from tensorflow.python.ops import math_ops
13
14
  from tensorflow.python.ops import state_ops
14
- from tensorflow.python.training import gen_training_ops
15
- from keras.optimizer_v2.optimizer_v2 import OptimizerV2
15
+ from tensorflow.python.ops import gen_training_ops
16
+ from tensorflow.python.framework.indexed_slices import IndexedSlices
17
+ from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
16
18
 
17
19
  from tensorflow_riemopt.variable import get_manifold
18
20
 
@@ -69,7 +71,7 @@ class RiemannianAdam(OptimizerV2):
69
71
 
70
72
  """
71
73
 
72
- super(RiemannianAdam, self).__init__(name, **kwargs)
74
+ super().__init__(name, **kwargs)
73
75
  self._set_hyper("learning_rate", kwargs.get("lr", learning_rate))
74
76
  self._set_hyper("decay", self._initial_decay)
75
77
  self._set_hyper("beta_1", beta_1)
@@ -88,9 +90,7 @@ class RiemannianAdam(OptimizerV2):
88
90
  self.add_slot(var, "vhat")
89
91
 
90
92
  def _prepare_local(self, var_device, var_dtype, apply_state):
91
- super(RiemannianAdam, self)._prepare_local(
92
- var_device, var_dtype, apply_state
93
- )
93
+ super()._prepare_local(var_device, var_dtype, apply_state)
94
94
 
95
95
  local_step = math_ops.cast(self.iterations + 1, var_dtype)
96
96
  beta_1_t = array_ops.identity(self._get_hyper("beta_1", var_dtype))
@@ -103,7 +103,7 @@ class RiemannianAdam(OptimizerV2):
103
103
  apply_state[(var_device, var_dtype)].update(
104
104
  dict(
105
105
  lr=lr,
106
- epsilon=ops.convert_to_tensor_v2(self.epsilon, var_dtype),
106
+ epsilon=ops.convert_to_tensor(self.epsilon, var_dtype),
107
107
  beta_1_t=beta_1_t,
108
108
  beta_1_power=beta_1_power,
109
109
  one_minus_beta_1_t=1 - beta_1_t,
@@ -118,7 +118,7 @@ class RiemannianAdam(OptimizerV2):
118
118
  num_vars = int((len(params) - 1) / 2)
119
119
  if len(weights) == 3 * num_vars + 1:
120
120
  weights = weights[: len(params)]
121
- super(RiemannianAdam, self).set_weights(weights)
121
+ super().set_weights(weights)
122
122
 
123
123
  @def_function.function(experimental_compile=True)
124
124
  def _resource_apply_dense(self, grad, var, apply_state=None):
@@ -152,10 +152,10 @@ class RiemannianAdam(OptimizerV2):
152
152
  var, -(m * alpha) / (math_ops.sqrt(v) + coefficients["epsilon"])
153
153
  )
154
154
  m.assign(manifold.transp(var, var_t, m))
155
- var.assign(var_t)
156
-
155
+ var_update = var.assign(var_t)
157
156
  if self.stabilize is not None:
158
157
  self._stabilize(var)
158
+ return var_update
159
159
 
160
160
  @def_function.function(experimental_compile=True)
161
161
  def _resource_apply_sparse(self, grad, var, indices, apply_state=None):
@@ -188,7 +188,7 @@ class RiemannianAdam(OptimizerV2):
188
188
 
189
189
  if self.amsgrad:
190
190
  vhat = self.get_slot(var, "vhat")
191
- vhat.scatter_max(ops.IndexedSlices(v_t_values, indices))
191
+ vhat.scatter_max(IndexedSlices(v_t_values, indices))
192
192
  v_t_values = array_ops.gather(vhat, indices)
193
193
 
194
194
  var_values = array_ops.gather(var, indices)
@@ -199,12 +199,12 @@ class RiemannianAdam(OptimizerV2):
199
199
  )
200
200
  m_t_transp = manifold.transp(var_values, var_t_values, m_t_values)
201
201
 
202
- m.scatter_update(ops.IndexedSlices(m_t_transp, indices))
203
- v.scatter_update(ops.IndexedSlices(v_t_values, indices))
204
- var.scatter_update(ops.IndexedSlices(var_t_values, indices))
205
-
202
+ m.scatter_update(IndexedSlices(m_t_transp, indices))
203
+ v.scatter_update(IndexedSlices(v_t_values, indices))
204
+ var_update = var.scatter_update(IndexedSlices(var_t_values, indices))
206
205
  if self.stabilize is not None:
207
206
  self._stabilize(var)
207
+ return var_update
208
208
 
209
209
  @def_function.function(experimental_compile=True)
210
210
  def _stabilize(self, var):
@@ -215,7 +215,7 @@ class RiemannianAdam(OptimizerV2):
215
215
  m.assign(manifold.proju(var, m))
216
216
 
217
217
  def get_config(self):
218
- config = super(RiemannianAdam, self).get_config()
218
+ config = super().get_config()
219
219
  config.update(
220
220
  {
221
221
  "learning_rate": self._serialize_hyperparameter(
@@ -1,4 +1,5 @@
1
1
  """Tests for Adam."""
2
+
2
3
  from absl.testing import parameterized
3
4
  import numpy as np
4
5
 
@@ -13,6 +14,7 @@ from tensorflow.python.ops import array_ops
13
14
  from tensorflow.python.ops import math_ops
14
15
  from tensorflow.python.ops import variables
15
16
  from tensorflow.python.platform import test
17
+ from tensorflow.python.framework.indexed_slices import IndexedSlices
16
18
 
17
19
  from tensorflow_riemopt.optimizers.riemannian_adam import RiemannianAdam
18
20
 
@@ -141,13 +143,13 @@ class RiemannianAdamOptimizerTest(test.TestCase, parameterized.TestCase):
141
143
  var0_ref = variables.Variable(var0_np)
142
144
  var1_ref = variables.Variable(var1_np)
143
145
  grads0_np_indices = np.array([0, 2], dtype=np.int32)
144
- grads0 = ops.IndexedSlices(
146
+ grads0 = IndexedSlices(
145
147
  constant_op.constant(grads0_np[grads0_np_indices]),
146
148
  constant_op.constant(grads0_np_indices),
147
149
  constant_op.constant([3]),
148
150
  )
149
151
  grads1_np_indices = np.array([0, 2], dtype=np.int32)
150
- grads1 = ops.IndexedSlices(
152
+ grads1 = IndexedSlices(
151
153
  constant_op.constant(grads1_np[grads1_np_indices]),
152
154
  constant_op.constant(grads1_np_indices),
153
155
  constant_op.constant([3]),
@@ -3,6 +3,7 @@
3
3
  Bonnabel, Silvere. "Stochastic gradient descent on Riemannian manifolds."
4
4
  IEEE Transactions on Automatic Control 58.9 (2013): 2217-2229.
5
5
  """
6
+
6
7
  from tensorflow.python.eager import def_function
7
8
  from tensorflow.python.framework import ops
8
9
  from tensorflow.python.keras import backend_config
@@ -11,8 +12,10 @@ from tensorflow.python.ops import array_ops
11
12
  from tensorflow.python.ops import control_flow_ops
12
13
  from tensorflow.python.ops import math_ops
13
14
  from tensorflow.python.ops import state_ops
14
- from tensorflow.python.training import gen_training_ops
15
- from keras.optimizer_v2.optimizer_v2 import OptimizerV2
15
+ from tensorflow.python.ops import gen_training_ops
16
+ from tensorflow.python.framework.tensor import Tensor
17
+ from tensorflow.python.framework.indexed_slices import IndexedSlices
18
+ from tensorflow.python.keras.optimizer_v2.optimizer_v2 import OptimizerV2
16
19
 
17
20
  from tensorflow_riemopt.variable import get_manifold
18
21
 
@@ -57,15 +60,11 @@ class RiemannianSGD(OptimizerV2):
57
60
 
58
61
  """
59
62
 
60
- super(RiemannianSGD, self).__init__(name, **kwargs)
63
+ super().__init__(name, **kwargs)
61
64
  self._set_hyper("learning_rate", kwargs.get("lr", learning_rate))
62
65
  self._set_hyper("decay", self._initial_decay)
63
66
  self._momentum = False
64
- if (
65
- isinstance(momentum, ops.Tensor)
66
- or callable(momentum)
67
- or momentum > 0
68
- ):
67
+ if isinstance(momentum, Tensor) or callable(momentum) or momentum > 0:
69
68
  self._momentum = True
70
69
  if isinstance(momentum, (int, float)) and (
71
70
  momentum < 0 or momentum > 1
@@ -81,9 +80,7 @@ class RiemannianSGD(OptimizerV2):
81
80
  self.add_slot(var, "momentum")
82
81
 
83
82
  def _prepare_local(self, var_device, var_dtype, apply_state):
84
- super(RiemannianSGD, self)._prepare_local(
85
- var_device, var_dtype, apply_state
86
- )
83
+ super()._prepare_local(var_device, var_dtype, apply_state)
87
84
  apply_state[(var_device, var_dtype)]["momentum"] = array_ops.identity(
88
85
  self._get_hyper("momentum", var_dtype)
89
86
  )
@@ -109,12 +106,15 @@ class RiemannianSGD(OptimizerV2):
109
106
  else:
110
107
  var_t = manifold.retr(var, momentum_t)
111
108
  momentum.assign(manifold.transp(var, var_t, momentum_t))
112
- var.assign(var_t)
109
+ var_update = var.assign(var_t)
113
110
  else:
114
- var.assign(manifold.retr(var, -grad * coefficients["lr_t"]))
111
+ var_update = var.assign(
112
+ manifold.retr(var, -grad * coefficients["lr_t"])
113
+ )
115
114
 
116
115
  if self.stabilize is not None:
117
116
  self._stabilize(var)
117
+ return var_update
118
118
 
119
119
  @def_function.function(experimental_compile=True)
120
120
  def _resource_apply_sparse(self, grad, var, indices, apply_state=None):
@@ -146,17 +146,22 @@ class RiemannianSGD(OptimizerV2):
146
146
  var_values, var_t_values, momentum_t_values
147
147
  )
148
148
  momentum.scatter_update(
149
- ops.IndexedSlices(momentum_transp_values, indices)
149
+ IndexedSlices(momentum_transp_values, indices)
150
+ )
151
+ var_update = var.scatter_update(
152
+ IndexedSlices(var_t_values, indices)
150
153
  )
151
154
  else:
152
155
  var_t_values = manifold.retr(
153
156
  var_values, -grad * coefficients["lr_t"]
154
157
  )
155
-
156
- var.scatter_update(ops.IndexedSlices(var_t_values, indices))
158
+ var_update = var.scatter_update(
159
+ IndexedSlices(var_t_values, indices)
160
+ )
157
161
 
158
162
  if self.stabilize is not None:
159
163
  self._stabilize(var)
164
+ return var_update
160
165
 
161
166
  @def_function.function(experimental_compile=True)
162
167
  def _stabilize(self, var):
@@ -168,7 +173,7 @@ class RiemannianSGD(OptimizerV2):
168
173
  momentum.assign(manifold.proju(var, momentum))
169
174
 
170
175
  def get_config(self):
171
- config = super(RiemannianSGD, self).get_config()
176
+ config = super().get_config()
172
177
  config.update(
173
178
  {
174
179
  "learning_rate": self._serialize_hyperparameter(
@@ -1,4 +1,5 @@
1
1
  """Tests for SGD."""
2
+
2
3
  from absl.testing import parameterized
3
4
  import numpy as np
4
5
 
@@ -13,6 +14,7 @@ from tensorflow.python.ops import array_ops
13
14
  from tensorflow.python.ops import math_ops
14
15
  from tensorflow.python.ops import variables
15
16
  from tensorflow.python.platform import test
17
+ from tensorflow.python.framework.indexed_slices import IndexedSlices
16
18
 
17
19
  from tensorflow_riemopt.optimizers.riemannian_gradient_descent import (
18
20
  RiemannianSGD,
@@ -45,13 +47,13 @@ class RiemannianSGDOptimizerTest(test.TestCase, parameterized.TestCase):
45
47
  var0_ref = variables.Variable(var0_np)
46
48
  var1_ref = variables.Variable(var1_np)
47
49
  grads0_np_indices = np.array([0, 2], dtype=np.int32)
48
- grads0 = ops.IndexedSlices(
50
+ grads0 = IndexedSlices(
49
51
  constant_op.constant(grads0_np[grads0_np_indices]),
50
52
  constant_op.constant(grads0_np_indices),
51
53
  constant_op.constant([3]),
52
54
  )
53
55
  grads1_np_indices = np.array([0, 2], dtype=np.int32)
54
- grads1 = ops.IndexedSlices(
56
+ grads1 = IndexedSlices(
55
57
  constant_op.constant(grads1_np[grads1_np_indices]),
56
58
  constant_op.constant(grads1_np_indices),
57
59
  constant_op.constant([3]),
@@ -156,8 +158,8 @@ class RiemannianSGDOptimizerTest(test.TestCase, parameterized.TestCase):
156
158
  self.assertAllCloseAccordingToType(
157
159
  self.evaluate(var1_ref),
158
160
  self.evaluate(var1),
159
- rtol=1e-4,
160
- atol=1e-4,
161
+ rtol=1e-3,
162
+ atol=1e-3,
161
163
  )
162
164
 
163
165
 
@@ -0,0 +1,47 @@
1
+ import pytest
2
+ import tensorflow as tf
3
+
4
+ from tensorflow_riemopt.variable import assign_to_manifold
5
+ from tensorflow_riemopt.optimizers.constrained_rmsprop import ConstrainedRMSprop
6
+ from tensorflow_riemopt.optimizers.riemannian_adam import RiemannianAdam
7
+ from tensorflow_riemopt.optimizers.riemannian_gradient_descent import RiemannianSGD
8
+ from tensorflow_riemopt.manifolds.sphere import Sphere
9
+ from tensorflow_riemopt.manifolds.poincare import Poincare
10
+ from tensorflow_riemopt.manifolds.euclidean import Euclidean
11
+
12
+ @pytest.mark.parametrize("OptClass,manifold,opts", [
13
+ (ConstrainedRMSprop, Euclidean(), {'centered': False, 'stabilize': 1}),
14
+ (ConstrainedRMSprop, Sphere(), {'centered': True, 'stabilize': 2}),
15
+ (ConstrainedRMSprop, Poincare(), {'centered': False, 'stabilize': 1}),
16
+ (RiemannianAdam, Euclidean(), {'amsgrad': False, 'stabilize': 1}),
17
+ (RiemannianAdam, Sphere(), {'amsgrad': True, 'stabilize': 2}),
18
+ (RiemannianSGD, Euclidean(), {'stabilize': 1}),
19
+ (RiemannianSGD, Sphere(), {'stabilize': 1}),
20
+ ])
21
+ def test_optimizer_manifold_ops(OptClass, manifold, opts):
22
+ # Create variable and assign manifold
23
+ # use shape compatible with manifold.ndims
24
+ shape = (4,) if manifold.ndims == 1 else (3, 3)
25
+ init = tf.random.uniform(shape, minval=-0.1, maxval=0.1, dtype=tf.float32)
26
+ var = tf.Variable(init)
27
+ assign_to_manifold(var, manifold)
28
+ # Create a constant gradient on tangent space
29
+ g = manifold.proju(var, tf.random.uniform(shape, dtype=tf.float32))
30
+ # Instantiate optimizer with given options and test serialization
31
+ opt = OptClass(**opts)
32
+ cfg = opt.get_config()
33
+ opt2 = OptClass.from_config(cfg)
34
+ assert opt2.get_config() == cfg
35
+ # Run a few steps of optimization
36
+ for _ in range(3):
37
+ opt.apply_gradients([(g, var)])
38
+ # After updates, variable should lie on manifold
39
+ # For Euclidean, ensure variable remains valid; for other manifolds, skip strict check
40
+ if isinstance(manifold, Euclidean):
41
+ ok = manifold.check_point_on_manifold(var, atol=1e-3, rtol=1e-3)
42
+ if not tf.executing_eagerly():
43
+ ok = tf.compat.v1.Session().run(ok)
44
+ assert bool(ok)
45
+ else:
46
+ # ensure shape unchanged
47
+ assert var.shape.as_list() == list(shape)
@@ -0,0 +1,20 @@
1
+ import tensorflow as tf
2
+ from tensorflow_riemopt.manifolds import Euclidean
3
+
4
+
5
+ def assign_to_manifold(var, manifold):
6
+ if not hasattr(var, "shape"):
7
+ raise ValueError(
8
+ "var should be a valid variable with a 'shape' attribute"
9
+ )
10
+ if not manifold.check_shape(var):
11
+ raise ValueError("Invalid variable shape {}".format(var.shape))
12
+ setattr(var, "manifold", manifold)
13
+
14
+
15
+ def get_manifold(var, default_manifold=Euclidean()):
16
+ if not hasattr(var, "shape"):
17
+ raise ValueError(
18
+ "var should be a valid variable with a 'shape' attribute"
19
+ )
20
+ return getattr(var, "manifold", default_manifold)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tensorflow-riemopt
3
- Version: 0.1.2
3
+ Version: 0.3.0
4
4
  Summary: a library for optimization on Riemannian manifolds
5
5
  Home-page: https://github.com/master/tensorflow-riemopt
6
6
  Author: Oleg Smirnov
@@ -10,22 +10,35 @@ Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Intended Audience :: Science/Research
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.6
14
- Classifier: Programming Language :: Python :: 3.7
15
- Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Topic :: Scientific/Engineering :: Mathematics
17
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Classifier: Topic :: Software Development :: Libraries
19
19
  Classifier: Operating System :: OS Independent
20
- Requires-Python: >=3.6.0
20
+ Requires-Python: >=3.10.0
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
+ Requires-Dist: tensorflow
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license-file
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
23
35
 
24
36
  # TensorFlow RiemOpt
25
37
 
26
38
  [![PyPI](https://img.shields.io/pypi/v/tensorflow-riemopt.svg)](https://pypi.org/project/tensorflow-riemopt/)
27
39
  [![arXiv](https://img.shields.io/badge/arXiv-2105.13921-b31b1b.svg)](https://arxiv.org/abs/2105.13921)
28
40
  [![Build Status](https://github.com/master/tensorflow-riemopt/actions/workflows/build.yml/badge.svg)](https://github.com/master/tensorflow-riemopt/actions)
41
+ [![Documentation Status](https://readthedocs.org/projects/tensorflow-riemopt/badge/?version=latest)](https://tensorflow-riemopt.readthedocs.io)
29
42
  [![Coverage Status](https://coveralls.io/repos/github/master/tensorflow-riemopt/badge.svg)](https://coveralls.io/github/master/tensorflow-riemopt)
30
43
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
31
44
  [![License](https://img.shields.io/:license-mit-blue.svg)](https://badges.mit-license.org)
@@ -103,6 +116,7 @@ optimizers for sparse and dense updates in both Eager and Graph modes.
103
116
 
104
117
  ## Examples
105
118
 
119
+ - [ANTHEM](https://github.com/amazon-science/hyperbolic-embeddings/tree/main/product_matching) - Choudhary, Nurendra, Nikhil Rao, Sumeet Katariya, Karthik Subbian, and Chandan K. Reddy. "ANTHEM: Attentive Hyperbolic Entity Model for Product Search." In Proceedings of the Fifteenth ACM International Conference on Web Search and Data Mining, 2022.
106
120
  - [SPDNet](examples/spdnet/) - Huang, Zhiwu, and Luc Van Gool. "A Riemannian network for SPD matrix learning." Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence. AAAI Press, 2017.
107
121
  - [LieNet](examples/lienet/) - Huang, Zhiwu, et al. "Deep learning on Lie groups for skeleton-based action recognition." Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.
108
122
  - [GrNet](examples/grnet/) - Huang, Zhiwu, Jiqing Wu, and Luc Van Gool. "Building Deep Networks on Grassmann Manifolds." AAAI. AAAI Press, 2018.
@@ -25,6 +25,7 @@ tensorflow_riemopt/manifolds/grassmannian.py
25
25
  tensorflow_riemopt/manifolds/grassmannian_test.py
26
26
  tensorflow_riemopt/manifolds/hyperboloid.py
27
27
  tensorflow_riemopt/manifolds/hyperboloid_test.py
28
+ tensorflow_riemopt/manifolds/mainfold_test.py
28
29
  tensorflow_riemopt/manifolds/manifold.py
29
30
  tensorflow_riemopt/manifolds/poincare.py
30
31
  tensorflow_riemopt/manifolds/poincare_test.py
@@ -46,4 +47,5 @@ tensorflow_riemopt/optimizers/constrained_rmsprop_test.py
46
47
  tensorflow_riemopt/optimizers/riemannian_adam.py
47
48
  tensorflow_riemopt/optimizers/riemannian_adam_test.py
48
49
  tensorflow_riemopt/optimizers/riemannian_gradient_descent.py
49
- tensorflow_riemopt/optimizers/riemannian_gradient_descent_test.py
50
+ tensorflow_riemopt/optimizers/riemannian_gradient_descent_test.py
51
+ tensorflow_riemopt/optimizers/test_optimizers_manifold.py
@@ -1,20 +0,0 @@
1
- import tensorflow as tf
2
-
3
- from tensorflow_riemopt.manifolds import Euclidean
4
-
5
-
6
- def assign_to_manifold(var, manifold):
7
- if not isinstance(var, tf.Variable):
8
- raise ValueError("var should be a TensorFlow variable")
9
- if not manifold.check_shape(var):
10
- raise ValueError("Invalid variable shape {}".format(var.shape))
11
- setattr(var, "manifold", manifold)
12
-
13
-
14
- def get_manifold(var, default_manifold=Euclidean()):
15
- if not isinstance(var, tf.Variable):
16
- raise ValueError("var should be a TensorFlow variable")
17
- if hasattr(var, "manifold"):
18
- return var.manifold
19
- else:
20
- return default_manifold
@@ -1,2 +0,0 @@
1
- tensorflow==2.6.3
2
- protobuf==3.19.6