# 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.R)
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

Notes

By default, no error is raised if exponential map is not implemented. If so, the best approximation to exponential map is applied instead.

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 more (tensors) – other tangent vectors at point $$x$$ to be transported transported point tensor

Notes

By default, no error is raised if exponential map is not implemented. If so, the best approximation to exponential map is applied instead.

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 an retraction 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 more (tensors) – other tangent vector at point $$x$$ to be transported 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$$ more (tensors) – other tangent vectors at point $$x$$ to be transported 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)$$.

Parameters: u (tensor) – tangent vector at point $$x$$ v (tensor) – tangent vector at point $$x$$ to be transported more (tensors) – other tangent vectors at point $$x$$ to be transported transported tensor(s) tensor or tuple of tensors
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 more (tensors) – other tangent vectors at point $$x$$ to be transported transported tensor(s) tensor or tuple of tensors
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