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 (strint) – 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"
Returns: Return type: scalar

expmap
(u)[source]¶ Perform an exponential map \(\operatorname{Exp}_x(u)\).
Parameters: u (tensor) – tangent vector at point \(x\) Returns: transported point Return type: 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
Returns: transported point
Return type: 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?
Returns: inner product (broadcasted)
Return type: scalar

logmap
(y)[source]¶ Perform an logarithmic map \(\operatorname{Log}_{x}(y)\).
Parameters: y (tensor) – point on the manifold Returns: tangent vector Return type: 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 Returns: projected vector Return type: tensor

retr
(u)[source]¶ Perform a retraction from point \(x\) with given direction \(u\).
Parameters: u (tensor) – tangent vector at point \(x\) Returns: transported point Return type: 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
Returns: transported point and vectors
Return type: 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\)
Returns: transported tensor(s)
Return type: 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, nonexact, implementation is used.
Parameters:  u (tensor) – tangent vector at point \(x\)
 v (tensor) – tangent vector at point \(x\) to be transported
Returns: transported tensor
Return type: 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
Returns: transported tensor
Return type: 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 ifdata
is not ageoopt.ManifoldTensor