Sphere

\(\operatorname{Sphere}(n, r)\) is the sphere in \(\mathbb{R}^n\) with radius \(r\):

\[\operatorname{Sphere}(n,r) = \{x \in \mathbb{R}^n\:\mid\:\lVert x \rVert = r\}\]

Warning

In mathematics, \(\mathbb{S}^n\) represents the \(n\)-dimensional sphere. With this notation, \(\operatorname{Sphere}(n, 1.) = \mathbb{S}^{n-1}\).

class geotorch.Sphere(size, radius=1.0)[source]

Sphere as a map from the tangent space onto the sphere using the exponential map.

Parameters
  • size (torch.size) – Size of the tensor to be parametrized

  • radius (float) – Optional. Radius of the sphere. A positive number. Default: 1.

sample()[source]

Returns a uniformly sampled vector on the sphere.

in_manifold(x, eps=1e-05)[source]

Checks that a vector is on the sphere.

For tensors with more than 2 dimensions the first dimensions are treated as batch dimensions.

Parameters
  • X (torch.Tensor) – The vector to be checked.

  • eps (float) – Optional. Threshold at which the norm is considered to be equal to 1. Default: 1e-5

class geotorch.SphereEmbedded(size, radius=1.0)[source]

Sphere as the orthogonal projection from \(\mathbb{R}^n\) to \(\mathbb{S}^{n-1}\), that is, \(x \mapsto \frac{x}{\lVert x \rVert}\).

Parameters
  • size (torch.size) – Size of the tensor to be parametrized

  • radius (float) – Optional. Radius of the sphere. A positive number. Default: 1.

sample()[source]

Returns a uniformly sampled vector on the sphere.

in_manifold(x, eps=1e-05)[source]

Checks that a vector is on the sphere.

For tensors with more than 2 dimensions the first dimensions are treated as batch dimensions.

Parameters
  • X (torch.Tensor) – The vector to be checked.

  • eps (float) – Optional. Threshold at which the norm is considered to be equal to 1. Default: 1e-5

geotorch.sphere.uniform_init_sphere_(x, r=1.0)[source]

Samples a point uniformly on the sphere into the tensor x. If x has \(d > 1\) dimensions, the first \(d-1\) dimensions are treated as batch dimensions.