torch_topological.data
Module for various data operations and data set creation strategies.
- torch_topological.data.sample_from_annulus(n, r, R, seed=None)[source]
Sample points from a 2D annulus.
This function samples
N
points from an annulus with inner radiusr
and outer radiusR
.- Parameters:
n (int) – Number of points to sample
r (float) – Inner radius of annulus
R (float) – Outer radius of annulus
seed (int, instance of
np.random.Generator
, orNone
) – Seed for the random number generator, or an instance of such a generator. If set toNone
, the default random number generator will be used.
- Returns:
Tensor containing sampled coordinates.
- Return type:
torch.tensor of shape
(n, 2)
- torch_topological.data.sample_from_disk(n=100, r=0.9, R=1.0, seed=None)[source]
Sample points from disk.
- Parameters:
n (int) – Number of points to sample.
r (float) – Minimum radius, i.e. the radius of the inner circle of a perfect sampling.
R (float) – Maximum radius, i.e. the radius of the outer circle of a perfect sampling.
seed (int, instance of
np.random.Generator
, orNone
) – Seed for the random number generator, or an instance of such a generator. If set toNone
, the default random number generator will be used.
- Returns:
Tensor containing the sampled coordinates.
- Return type:
torch.tensor of shape
(n, 2)
- torch_topological.data.sample_from_sphere(n=100, d=2, r=1, noise=None, ambient=None, seed=None)[source]
Sample
n
data points from ad
-sphere ind + 1
dimensions.- Parameters:
n (int) – Number of data points in shape.
d (int) – Dimension of the sphere.
r (float) – Radius of sphere.
noise (float or None) – Optional noise factor. If set, data coordinates will be perturbed by a standard normal distribution, scaled by
noise
.ambient (int or None) – Embed the sphere into a space with ambient dimension equal to
ambient
. The sphere is randomly rotated into this high-dimensional space.seed (int, instance of
np.random.Generator
, orNone
) – Seed for the random number generator, or an instance of such a generator. If set toNone
, the default random number generator will be used.
- Returns:
Tensor of sampled coordinates. If
ambient
is set, array will be of shape(n, ambient)
. Else, array will be of shape(n, d + 1)
.- Return type:
torch.tensor
Notes
This function was originally authored by Nathaniel Saul as part of the
tadasets
package. [tadasets]References
- torch_topological.data.sample_from_torus(n, d=3, r=1.0, R=2.0, seed=None)[source]
Sample points uniformly from torus and embed it in
d
dimensions.- Parameters:
n (int) – Number of points to sample
d (int) – Number of dimensions.
r (float) – Radius of the ‘tube’ of the torus.
R (float) – Radius of the torus, i.e. the distance from the centre of the ‘tube’ to the centre of the torus.
seed (int, instance of
np.random.Generator
, orNone
) – Seed for the random number generator, or an instance of such a generator. If set toNone
, the default random number generator will be used.
- Returns:
Tensor of sampled coordinates.
- Return type:
torch.tensor of shape
(n, d)
- torch_topological.data.sample_from_unit_cube(n, d=3, seed=None)[source]
Sample points uniformly from unit cube in
d
dimensions.- Parameters:
n (int) – Number of points to sample
d (int) – Number of dimensions.
seed (int, instance of
np.random.Generator
, orNone
) – Seed for the random number generator, or an instance of such a generator. If set toNone
, the default random number generator will be used.
- Returns:
Tensor containing the sampled coordinates.
- Return type:
torch.tensor of shape
(n, d)