manifolds¶
Package Contents¶
Euclidean Manifold class. Usually we refer it as R^n. |
|
PoicareBall Manifold class. |
- class Euclidean(**kwargs)¶
Bases:
topmost.models.hierarchical.HyperMiner.manifolds.base.ManifoldEuclidean Manifold class. Usually we refer it as R^n.
Initialize an Euclidean manifold. :param **kwargs: Description
- name = 'Euclidean'¶
- proj(x, c)¶
A projection function that prevents x from leaving the manifold. :param x: A point should be on the manifold, but it may not meet the manifold constraints. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
A projected point, meeting the manifold constraints.
- Return type:
tensor
- proj_tan(v, x, c)¶
A projection function that prevents v from leaving the tangent space of point x. :param v: A point should be on the tangent space, but it may not meet the manifold constraints. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
A projected point, meeting the tangent space constraints.
- Return type:
tensor
- proj_tan0(v, c)¶
A projection function that prevents v from leaving the tangent space of origin point. :param v: A point should be on the tangent space, but it may not meet the manifold constraints. :type v: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
A projected point, meeting the tangent space constraints.
- Return type:
tensor
- expmap(v, x, c)¶
Map a point v in the tangent space of point x to the manifold. :param v: A point in the tangent space of point x. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping tangent point v to the manifold.
- Return type:
tensor
- expmap0(v, c)¶
Map a point v in the tangent space of origin point to the manifold. :param v: A point in the tangent space of origin point. :type v: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping tangent point v to the manifold.
- Return type:
tensor
- logmap(y, x, c)¶
Map a point y on the manifold to the tangent space of x. :param y: A point on the manifold. :type y: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping y to the tangent space of x.
- Return type:
tensor
- logmap0(y, c)¶
Map a point y on the manifold to the tangent space of origin point. :param y: A point on the manifold. :type y: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping y to the tangent space of origin point.
- Return type:
tensor
- ptransp(v, x, y, c)¶
Parallel transport function, used to move point v in the tangent space of x to the tangent space of y. :param v: A point in the tangent space of x. :type v: tensor :param x: A point on the manifold. :type x: tensor :param y: A point on the manifold. :type y: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of transporting v from the tangent space at x to the tangent space at y.
- Return type:
tensor
- ptransp0(v, x, c)¶
Parallel transport function, used to move point v in the tangent space of origin point to the tangent space of y. :param v: A point in the tangent space of origin point. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of transporting v from the tangent space at origin point to the tangent space at y.
- Return type:
tensor
- dist(x, y, c)¶
Calculate the squared geodesic/distance between x and y. :param x: A point on the manifold. :type x: tensor :param y: A point on the manifold. :type y: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
the geodesic/distance between x and y.
- Return type:
tensor
- egrad2rgrad(grad, x, c)¶
Computes Riemannian gradient from the Euclidean gradient, typically used in Riemannian optimizers. :param grad: Euclidean gradient at x. :type grad: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
Riemannian gradient at x.
- Return type:
tensor
- inner(v1, v2, x, c, keep_shape=False)¶
Computes the inner product of a pair of tangent vectors v1 and v2 at x. :param v1: A tangent point at x. :type v1: tensor :param v2: A tangent point at x. :type v2: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor :param keep_shape: Whether the output tensor keeps shape or not. :type keep_shape: bool, optional
- Returns:
The inner product of v1 and v2 at x.
- Return type:
tensor
- class PoincareBall¶
Bases:
topmost.models.hierarchical.HyperMiner.manifolds.base.ManifoldPoicareBall Manifold class.
We use the following convention: x0^2 + x1^2 + … + xd^2 < 1 / c. (c < 0)
So that the Poincare ball radius will be 1 / sqrt(-c). Notice that the more close c is to 0, the more flat space will be.
Initialize a manifold.
- name = 'PoincareBall'¶
- truncate_c¶
- proj(x, c)¶
A projection function that prevents x from leaving the manifold. :param x: A point should be on the manifold, but it may not meet the manifold constraints. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
A projected point, meeting the manifold constraints.
- Return type:
tensor
- proj_tan(v, x, c)¶
A projection function that prevents v from leaving the tangent space of point x. :param v: A point should be on the tangent space, but it may not meet the manifold constraints. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
A projected point, meeting the tangent space constraints.
- Return type:
tensor
- proj_tan0(v, c)¶
A projection function that prevents v from leaving the tangent space of origin point. :param v: A point should be on the tangent space, but it may not meet the manifold constraints. :type v: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
A projected point, meeting the tangent space constraints.
- Return type:
tensor
- expmap(v, x, c)¶
Map a point v in the tangent space of point x to the manifold. :param v: A point in the tangent space of point x. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping tangent point v to the manifold.
- Return type:
tensor
- expmap0(v, c)¶
Map a point v in the tangent space of origin point to the manifold. :param v: A point in the tangent space of origin point. :type v: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping tangent point v to the manifold.
- Return type:
tensor
- logmap(y, x, c)¶
Map a point y on the manifold to the tangent space of x. :param y: A point on the manifold. :type y: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping y to the tangent space of x.
- Return type:
tensor
- logmap0(y, c)¶
Map a point y on the manifold to the tangent space of origin point. :param y: A point on the manifold. :type y: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping y to the tangent space of origin point.
- Return type:
tensor
- ptransp(v, x, y, c)¶
Parallel transport function, used to move point v in the tangent space of x to the tangent space of y. :param v: A point in the tangent space of x. :type v: tensor :param x: A point on the manifold. :type x: tensor :param y: A point on the manifold. :type y: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of transporting v from the tangent space at x to the tangent space at y.
- Return type:
tensor
- ptransp0(v, x, c)¶
Parallel transport function, used to move point v in the tangent space of origin point to the tangent space of y. :param v: A point in the tangent space of origin point. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of transporting v from the tangent space at origin point to the tangent space at y.
- Return type:
tensor
- dist(x, y, c)¶
Calculate the squared geodesic/distance between x and y. :param x: A point on the manifold. :type x: tensor :param y: A point on the manifold. :type y: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
the geodesic/distance between x and y.
- Return type:
tensor
- egrad2rgrad(grad, x, c)¶
Computes Riemannian gradient from the Euclidean gradient, typically used in Riemannian optimizers. :param grad: Euclidean gradient at x. :type grad: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
Riemannian gradient at x.
- Return type:
tensor
- inner(v1, v2, x, c, keep_shape=False)¶
Computes the inner product of a pair of tangent vectors v1 and v2 at x. :param v1: A tangent point at x. :type v1: tensor :param v2: A tangent point at x. :type v2: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor :param keep_shape: Whether the output tensor keeps shape or not. :type keep_shape: bool, optional
- Returns:
The inner product of v1 and v2 at x.
- Return type:
tensor
- retraction(v, x, c)¶
Retraction is a continuous map function from tangent space to the manifold, typically used in Riemannian optimizers. The exp map is one of retraction functions. :param v: A tangent point at x. :type v: tensor :param x: A point on the manifold. :type x: tensor :param c: The manifold curvature. :type c: tensor
- Returns:
The result of mapping tangent point v at x to the manifold.
- Return type:
tensor
- _mobius_add(x, y, c)¶
- _mobius_mul(x, a, c)¶
- _mobius_matvec(x, a, c)¶
- _lambda_x(x, c)¶
- _gyration(x, y, v, c)¶