equiadapt.pointcloud package
Subpackages
- equiadapt.pointcloud.canonicalization package
- equiadapt.pointcloud.canonicalization_networks package
- Submodules
- equiadapt.pointcloud.canonicalization_networks.equivariant_networks module
- equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers module
- Module contents
Module contents
This package contains modules for the equiadapt pointcloud canonicalization.
- class equiadapt.pointcloud.ContinuousGroupPointcloudCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig)[source]
Bases:
ContinuousGroupCanonicalizationThis class represents a continuous group point cloud canonicalization.
- Parameters:
canonicalization_network (torch.nn.Module) – The canonicalization network.
canonicalization_hyperparams (DictConfig) – The hyperparameters for canonicalization.
- device
The device on which the operations are performed.
- canonicalize(x: Tensor, targets: List | None = None, **kwargs: Any) Tensor | Tuple[Tensor, List][source]
This method takes an image as input and returns the canonicalized image.
- Parameters:
x (torch.Tensor) – The input point cloud.
targets (Optional[List]) – The list of targets (optional).
**kwargs (Any) – Additional keyword arguments.
- Returns:
The canonicalized point cloud.
- Return type:
Union[torch.Tensor, Tuple[torch.Tensor, List]]
- get_groupelement(x: Tensor) dict[source]
This method takes the input image and maps it to the group element.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group element.
- Return type:
- Raises:
NotImplementedError – If the method is not implemented.
- class equiadapt.pointcloud.EquivariantPointcloudCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig)[source]
Bases:
ContinuousGroupPointcloudCanonicalizationThis class represents the equivariant point cloud canonicalization module.
It inherits from the ContinuousGroupPointcloudCanonicalization class.
- Parameters:
canonicalization_network (torch.nn.Module) – The canonicalization network module.
canonicalization_hyperparams (DictConfig) – The hyperparameters for the canonicalization.
- canonicalization_network
The canonicalization network module.
- Type:
torch.nn.Module
- canonicalization_hyperparams
The hyperparameters for the canonicalization.
- Type:
DictConfig
- class equiadapt.pointcloud.VNBatchNorm(num_features: int, dim: int)[source]
Bases:
ModuleVector Neuron Batch Normalization layer.
VNBatchNorm applies batch normalization to the input features.
- class equiadapt.pointcloud.VNBilinear(in_channels1: int, in_channels2: int, out_channels: int)[source]
Bases:
ModuleVector Neuron Bilinear layer.
VNBilinear applies a bilinear layer to the input features.
- forward(x: Tensor, labels: Tensor) Tensor[source]
Forward pass of the VNBilinear layer.
- Parameters:
x (torch.Tensor) – Input features of shape [B, N_feat, 3, N_samples, …].
labels (torch.Tensor) – Labels of shape [B, N_feat, N_samples].
- Returns:
Output features after applying the bilinear transformation.
- Return type:
torch.Tensor
- class equiadapt.pointcloud.VNLeakyReLU(in_channels: int, share_nonlinearity: bool = False, negative_slope: float = 0.2)[source]
Bases:
ModuleVector Neuron Leaky ReLU layer.
VNLLeakyReLU applies a LeakyReLU activation to the input features.
- class equiadapt.pointcloud.VNLinear(in_channels: int, out_channels: int)[source]
Bases:
ModuleVector Neuron Linear layer.
This layer applies a linear transformation to the input tensor.
- class equiadapt.pointcloud.VNLinearLeakyReLU(in_channels: int, out_channels: int, dim: int = 5, share_nonlinearity: bool = False, negative_slope: float = 0.2)[source]
Bases:
ModuleVector Neuron Linear Leaky ReLU layer.
VNLinearLeakyReLU applies a linear transformation followed by a LeakyReLU activation to the input features.
- class equiadapt.pointcloud.VNMaxPool(in_channels: int)[source]
Bases:
ModuleVector Neuron Max Pooling layer.
VNMaxPool applies max pooling to the input features.
- class equiadapt.pointcloud.VNSmall(hyperparams: DictConfig)[source]
Bases:
ModuleVNSmall is a small variant of the vector neuron equivariant network used for canonicalization of point clouds.
- Parameters:
hyperparams (DictConfig) – Hyperparameters for the network.
- conv_pos
Convolutional layer for positional encoding.
- Type:
- conv1
First convolutional layer.
- Type:
- bn1
Batch normalization layer.
- Type:
- conv2
Second convolutional layer.
- Type:
- dropout
Dropout layer.
- Type:
nn.Dropout
- forward(point_cloud: Tensor) Tensor[source]
Forward pass of the VNSmall network.
For every pointcloud in the batch, the network outputs three vectors that transform equivariantly with respect to SO3 group.
- Parameters:
point_cloud (torch.Tensor) – Input point cloud tensor of shape (batch_size, num_points, 3).
- Returns:
Output tensor of shape (batch_size, 3, 3).
- Return type:
torch.Tensor
- class equiadapt.pointcloud.VNSoftplus(in_channels: int, share_nonlinearity: bool = False, negative_slope: float = 0.0)[source]
Bases:
ModuleVector Neuron Softplus layer.
VNSoftplus applies a softplus activation to the input features.
- class equiadapt.pointcloud.VNStdFeature(in_channels: int, dim: int = 4, normalize_frame: bool = False, share_nonlinearity: bool = False, negative_slope: float = 0.2)[source]
Bases:
ModuleVector Neuron Standard Feature module.
This module performs standard feature extraction using Vector Neuron layers. It takes point features as input and applies a series of VNLinearLeakyReLU layers followed by a linear layer to produce the standard features.
- Shape:
Input: (B, N_feat, 3, N_samples, …)
- Output:
x_std: (B, N_feat, dim, N_samples, …)
z0: (B, dim, 3)
Example
>>> model = VNStdFeature(in_channels=64, dim=4, normalize_frame=True) >>> input = torch.randn(2, 64, 3, 100) >>> output, frame_vectors = model(input)
- forward(x: Tensor) Tuple[Tensor, Tensor][source]
Forward pass of the VNStdFeature module.
- Parameters:
x (torch.Tensor) – Input point features of shape (B, N_feat, 3, N_samples, …).
- Returns:
Tuple containing the standard features and the frame vectors.
- Return type:
Tuple[torch.Tensor, torch.Tensor]
Note
The frame vectors are computed only if normalize_frame is set to True.
The shape of the standard features depends on the value of dim.
- equiadapt.pointcloud.get_graph_feature_cross(x: Tensor, k: int = 20, idx: Tensor | None = None) Tensor[source]
Computes the graph feature cross for a given input tensor.
- Parameters:
x (torch.Tensor) – The input tensor of shape (batch_size, num_dims, num_points).
k (int, optional) – The number of nearest neighbors to consider. Defaults to 20.
idx (torch.Tensor, optional) – The indices of the nearest neighbors. Defaults to None.
- Returns:
The computed graph feature cross tensor of shape (batch_size, num_dims*3, num_points, k).
- Return type:
torch.Tensor
- equiadapt.pointcloud.knn(x: Tensor, k: int) Tensor[source]
Performs k-nearest neighbors search on a given set of points.
- Parameters:
x (torch.Tensor) – The input tensor representing a set of points. Shape: (batch_size, num_points, num_dimensions).
k (int) – The number of nearest neighbors to find.
- Returns:
- The indices of the k nearest neighbors for each point in x.
Shape: (batch_size, num_points, k).
- Return type:
torch.Tensor