geo_map.py¶

Geometric maps for manifolds and related methods for computing gradients for training. Provides the g-projection maps discussed in the GD-VAE paper for training with manifold latent spaces within machine learning methods.
If you find these codes or methods helpful for your project, please cite our related work.
- class geo_map.ManifoldDirectMapLayer(params)¶
This layer projects an input onto a manifold having a direct representation as an expression that can be backpropogated.
- __init__(params)¶
- Parameters:
params (dict) – the parameters of the map including
params [members]
Property
Description
func_map (function)
function for the direct mapping
params_map (dict)
paramaters for the mapping function
device (torch.device)
for the hardware device as a specific gpu, cpu, or other component.
- __module__ = 'geo_map'¶
- extra_repr()¶
Gives a string representation for the parameters.
- forward(input)¶
Performs the projection mapping of the input points \(x\) to the points \(z\) on the manifold.
- Parameters:
input (Tensor) – points \(x\) in the embedding space. Tensor of shape [num_samples,num_dim_x].
- Returns:
output (Tensor) – points \(z\) on the manifold projected from \(x\). Tensor of size [num_samples,num_dim_x].
- to(device)¶
Currently nothing extra to do to map to a device.
- training: bool¶
- class geo_map.ManifoldPointCloudLayer(params)¶
This layer maps an input onto a manifold having a point cloud representation and handles computing the associated gradients for use in backpropogation.
- __init__(params)¶
- Parameters:
params (dict) – collection of parameters for the mapping.
params [members]
Property
Description
u (Tensor)
coordinate parameterization for the manifold points
coordinate_chart (Tensor)
coordinate chart information
device (torch.device)
for the hardware device as a specific gpu, cpu, or other component
kdtree_params (dict)
for the parameters for the kdtree methods
- __module__ = 'geo_map'¶
- extra_repr()¶
Gives a string representation for the parameters.
- forward(input)¶
Performs the projection mapping of the input points :math:’x” to the points :math:’z’ on the manifold.
- Parameters:
input (Tensor) – points \(x\) in the embedding space. Tensor of shape [num_samples,num_dim_x].
- Returns:
points \(z\) on the manifold projected from \(x\). Tensor of size [num_samples,num_dim_x].
- Return type:
output (Tensor)
- to(device)¶
Maps the stored manifold points to the specified device.
- training: bool¶
- class geo_map.PointCloudMapFunc(*args, **kwargs)¶
Module layer which maps an input to nearest point in a manifold having a point cloud representation. This layer also handles computing the associated gradients for use in backpropogation and training methods.
- __module__ = 'geo_map'¶
- static backward(ctx, grad_output)¶
Computes the gradients of the projection map.
- static find_k_nearest_neighs_kdtree(X0, k, params)¶
Find the nearest neighbors on the manifold using for efficiency a kdtree data structure for the point cloud representation.
- Parameters:
X0 (Tensor) – input point to map to the manifold. Tensor of shape [num_pts,num_dim].
manifold_ptsX (Tensor) – points of the manifold point cloud representation. Tensor of shape [num_manifold_pts,num_dim].
kdtree_params (dict) – parameters for the kdtree methods. Giving ‘None’ will result in the use of default parameters.
- Returns:
(tuple) containing
X_neighs (Tensor) – giving the closest nearby points. Tensor of shape [num_pts,num_dim].
I_neighs (Tensor) – giving the indices of the closest points. Tensor of shape [num_pts,1].
- static find_nearest_manifold_pt_kdtree(X0, params)¶
Finds the nearest point on the manifold using for efficiency a kdtree data structure for the point cloud representation.
- Parameters:
X0 (Tensor) – input point to map to the manifold. Tensor of shape [num_pts,num_dim].
params (dict) – the parameters for the manifold map (matches find_k_nearest_neighs_kdtree()).
- Returns:
x (Tensor) – giving the closest nearby point. Tensor of shape [num_pts,num_dim].
- static forward(ctx, input, params=None)¶
Performs the projection mapping of the input points \(x\) to the points \(z\) on the manifold.
- Parameters:
ctx (dict) – pytorch context data structure.
input (Tensor) – points \(x\) in the embedding space. Tensor of shape [num_samples,num_dim_x].
params (dict) – the parameters for the mapping
- Returns:
output (Tensor) – points \(z\) on the manifold obtained from mapping \(x\). Tensor of size [num_samples,num_dim_x].
params [members]
Property
Description
u (Tensor)
coordinate parameterization for the manifold points
coordinate_chart (Tensor)
coordinate chart information
device (torch.device)
for the hardware device as a specific gpu, cpu, or other component
kdtree_params (dict)
for the parameters for the kdtree methods
- geo_map.map_clifford_torus(input, params)¶
Computes the clifford torus map as represented by a product-space of circles in \(R^{2n}\).
- Parameters:
input (Tensor) – input points \(x\) to map to the Clifford Torus.
params_map (dict) – parameters for the clifford torus map.
- Returns:
z (Tensor) – points mapped to the manifold
params_map [members]
Property
Description
num_circles (int)
(default is 2): for number of circles to use for the product-space
device (torch.device)
for the hardware device as a specific gpu, cpu, or other component.
- geo_map.map_sphere(input, params)¶
Computes the sphere map as represented in \(R^{n}\).
- Parameters:
input (Tensor) – input points \(x\) to map to the sphere.
params_map (dict) – parameters for the sphere map.
- Returns:
z (Tensor) – points mapped to the sphere.
params_map [members]
Property
Description
sphere_r (double)
(default is 1.0) radius of the sphere
epsilon (double)
(default is 1e-10) used to avoid dividing by zero
device (torch.device)
for the hardware device as a specific gpu, cpu, or other component