equiadapt.pointcloud.canonicalization_networks package
Submodules
equiadapt.pointcloud.canonicalization_networks.equivariant_networks module
- class equiadapt.pointcloud.canonicalization_networks.equivariant_networks.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
- equiadapt.pointcloud.canonicalization_networks.equivariant_networks.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.canonicalization_networks.equivariant_networks.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
equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers module
Layers for vector neuron networks
Taken from Vector Neurons: A General Framework for SO(3)-Equivariant Networks (https://arxiv.org/abs/2104.12229) paper and their codebase https://github.com/FlyingGiraffe/vnn
- class equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers.VNBatchNorm(num_features: int, dim: int)[source]
Bases:
ModuleVector Neuron Batch Normalization layer.
VNBatchNorm applies batch normalization to the input features.
- class equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers.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.canonicalization_networks.vector_neuron_layers.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.canonicalization_networks.vector_neuron_layers.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.canonicalization_networks.vector_neuron_layers.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.canonicalization_networks.vector_neuron_layers.VNMaxPool(in_channels: int)[source]
Bases:
ModuleVector Neuron Max Pooling layer.
VNMaxPool applies max pooling to the input features.
- class equiadapt.pointcloud.canonicalization_networks.vector_neuron_layers.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.canonicalization_networks.vector_neuron_layers.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.
Module contents
This package contains equivariant modules and networks for the equiadapt pointcloud canonicalization.
- class equiadapt.pointcloud.canonicalization_networks.VNBatchNorm(num_features: int, dim: int)[source]
Bases:
ModuleVector Neuron Batch Normalization layer.
VNBatchNorm applies batch normalization to the input features.
- class equiadapt.pointcloud.canonicalization_networks.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.canonicalization_networks.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.canonicalization_networks.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.canonicalization_networks.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.canonicalization_networks.VNMaxPool(in_channels: int)[source]
Bases:
ModuleVector Neuron Max Pooling layer.
VNMaxPool applies max pooling to the input features.
- class equiadapt.pointcloud.canonicalization_networks.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.canonicalization_networks.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.canonicalization_networks.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.canonicalization_networks.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.canonicalization_networks.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