# Tensors¶

class geoopt.tensor.ManifoldTensor[source]

Same as torch.Tensor that has information about its manifold.

Other Parameters:
manifold (geoopt.Manifold) – A manifold for the tensor, (default: geoopt.Euclidean)
dist(other, p=2)[source]

Return euclidean or geodesic distance between points on the manifold. Allows broadcasting.

Parameters: other (tensor) – p (str|int) – The norm to use. The default behaviour is not changed and is just euclidean distance. To compute geodesic distance, p should be set to "g" scalar
expmap(u)[source]

Perform an exponential map $$\operatorname{Exp}_x(u)$$.

Parameters: u (tensor) – tangent vector at point $$x$$ transported point tensor
expmap_transp(u, v, *more)[source]

Perform an exponential map and vector transport from point $$x$$ with given direction $$u$$.

Parameters: u (tensor) – tangent vector at point $$x$$ v (tensor) – tangent vector at point $$x$$ to be transported transported point tensor
inner(u, v=None)[source]

Inner product for tangent vectors at point $$x$$.

Parameters: u (tensor) – tangent vector at point $$x$$ v (tensor (optional)) – tangent vector at point $$x$$ keepdim (bool) – keep the last dim? inner product (broadcasted) scalar
logmap(y)[source]

Perform an logarithmic map $$\operatorname{Log}_{x}(y)$$.

Parameters: y (tensor) – point on the manifold tangent vector tensor
proj_()[source]

Inplace projection to the manifold.

Returns: same instance tensor
proju(u)[source]

Project vector $$u$$ on a tangent space for $$x$$, usually is the same as egrad2rgrad().

Parameters: u (tensor) – vector to be projected projected vector tensor
retr(u)[source]

Perform a retraction from point $$x$$ with given direction $$u$$.

Parameters: u (tensor) – tangent vector at point $$x$$ transported point tensor
retr_transp(u, v, *more)[source]

Perform a retraction + vector transport at once.

Parameters: v (tensor) – tangent vector at point $$x$$ to be transported u (tensor) – tangent vector at point $$x$$ (required keyword only argument) order (int) – order of retraction approximation, by default uses the simplest. Possible choices depend on a concrete manifold and -1 stays for exponential map transported point and vectors tuple of tensors

Notes

Sometimes this is a far more optimal way to preform retraction + vector transport

transp(y, v, *more)[source]

Perform vector transport $$\mathfrac{T}_{x\to y}(v)$$.

Parameters: y (tensor) – target point on the manifold v (tensor) – tangent vector at point $$x$$ transported tensor(s) tensor or tuple of tensors
transp_follow_expmap(u, v, *more)[source]

Perform vector transport following $$u$$: $$\mathfrac{T}_{x\to\operatorname{Exp}(x, u)}(v)$$.

Here, $$\operatorname{Exp}$$ is the best possible approximation of the true exponential map. There are cases when the exact variant is hard or impossible implement, therefore a fallback, non-exact, implementation is used.

Parameters: u (tensor) – tangent vector at point $$x$$ v (tensor) – tangent vector at point $$x$$ to be transported transported tensor tensor
transp_follow_retr(u, v, *more)[source]

Perform vector transport following $$u$$: $$\mathfrac{T}_{x\to\operatorname{retr}(x, u)}(v)$$.

This operation is sometimes is much more simpler and can be optimized.

Parameters: u (tensor) – tangent vector at point $$x$$ v (tensor) – tangent vector at point $$x$$ to be transported transported tensor tensor
class geoopt.tensor.ManifoldParameter[source]

Same as torch.nn.Parameter that has information about its manifold.

It should be used within torch.nn.Module to be recognized in parameter collection.

Other Parameters:
manifold (geoopt.Manifold (optional)) – A manifold for the tensor if data is not a geoopt.ManifoldTensor