equiadapt.images.canonicalization_networks package
Submodules
equiadapt.images.canonicalization_networks.custom_equivariant_networks module
- class equiadapt.images.canonicalization_networks.custom_equivariant_networks.CustomEquivariantNetwork(in_shape: Tuple[int, int, int, int], out_channels: int, kernel_size: int, group_type: str = 'rotation', num_rotations: int = 4, num_layers: int = 1, device: str = 'cpu')[source]
Bases:
ModuleThis class represents a custom equivariant network.
The network is equivariant to a specified group, which can be either the rotation group or the roto-reflection group. The network consists of a sequence of equivariant convolutional layers, each followed by a ReLU activation function.
equiadapt.images.canonicalization_networks.custom_group_equivariant_layers module
- class equiadapt.images.canonicalization_networks.custom_group_equivariant_layers.RotationEquivariantConv(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a rotation equivariant convolutional layer.
The layer is equivariant to a group of rotations. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- get_rotated_permuted_weights()[source]
Returns the weights of the layer after rotation and permutation.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, num_rotations, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_rotations, height, width).
- Return type:
torch.Tensor
- get_rotated_permuted_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation and permutation.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation and permutation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.custom_group_equivariant_layers.RotationEquivariantConvLift(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a rotation equivariant convolutional layer with lifting.
The layer is equivariant to a group of rotations. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_rotations, height, width).
- Return type:
torch.Tensor
- get_rotated_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.custom_group_equivariant_layers.RotoReflectionEquivariantConv(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a roto-reflection equivariant convolutional layer.
The layer is equivariant to a group of rotations and reflections. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- get_rotoreflected_permuted_weights()[source]
Returns the weights of the layer after rotation, reflection, and permutation.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, num_group_elements, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_group_elements, height, width).
- Return type:
torch.Tensor
- get_rotoreflected_permuted_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation, reflection, and permutation.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation, reflection, and permutation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.custom_group_equivariant_layers.RotoReflectionEquivariantConvLift(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a roto-reflection equivariant convolutional layer with lifting.
The layer is equivariant to a group of rotations and reflections. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- get_rotoreflected_weights()[source]
Returns the weights of the layer after rotation, reflection, and permutation.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_group_elements, height, width).
- Return type:
torch.Tensor
- get_rotoreflected_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation and reflection.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation, reflection, and permutation.
- Return type:
torch.Tensor
equiadapt.images.canonicalization_networks.custom_nonequivariant_networks module
- class equiadapt.images.canonicalization_networks.custom_nonequivariant_networks.ConvNetwork(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a convolutional neural network.
The network consists of a sequence of convolutional layers, each followed by batch normalization and a GELU activation function. The number of output channels of the convolutional layers increases after every third layer. The network ends with a fully connected layer.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the network.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the network. It has the shape (batch_size, out_vector_size).
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.custom_nonequivariant_networks.ResNet18Network(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a neural network based on the ResNet-18 architecture.
The network uses a pre-trained ResNet-18 model without its weights. The final fully connected layer of the ResNet-18 model is replaced with a new fully connected layer.
- resnet18
The ResNet-18 model.
- Type:
torchvision.models.ResNet
- class equiadapt.images.canonicalization_networks.custom_nonequivariant_networks.WideResNet101Network(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a neural network based on the WideResNetNetwork architecture.
The network uses a pre-trained WideResNet model. The final fully connected layer of the WideResNet101 model is replaced with a new fully connected layer.
- resnet18
The ResNet-18 model.
- Type:
torchvision.models.ResNet
- class equiadapt.images.canonicalization_networks.custom_nonequivariant_networks.WideResNet50Network(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a neural network based on the WideResNetNetwork architecture.
The network uses a pre-trained WideResNet model. The final fully connected layer of the WideResNet50 model is replaced with a new fully connected layer.
- resnet18
The ResNet-18 model.
- Type:
torchvision.models.ResNet
equiadapt.images.canonicalization_networks.escnn_networks module
- class equiadapt.images.canonicalization_networks.escnn_networks.ESCNNEquivariantNetwork(in_shape: tuple, out_channels: int, kernel_size: int, group_type: str = 'rotation', num_rotations: int = 4, num_layers: int = 1)[source]
Bases:
ModuleThis class represents an Equivariant Convolutional Neural Network (Equivariant CNN).
The network is equivariant to a group of transformations, which can be either rotations or roto-reflections. The network consists of a sequence of equivariant convolutional layers, each followed by batch normalization, a ReLU activation function, and dropout. The number of output channels of the convolutional layers is the same for all layers.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the network.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the network. It has the shape (batch_size, num_group_elements).
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.escnn_networks.ESCNNSteerableNetwork(in_shape: tuple, out_channels: int, kernel_size: int = 9, group_type: str = 'rotation', num_layers: int = 1)[source]
Bases:
ModuleThis class represents a Steerable Equivariant Convolutional Neural Network (Equivariant CNN).
The network is equivariant under all planar rotations. The network consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a FourierELU activation function. The number of output channels of the convolutional layers is the same for all layers.
- class equiadapt.images.canonicalization_networks.escnn_networks.ESCNNWRNEquivariantNetwork(in_shape: tuple, out_channels: int = 64, kernel_size: int = 9, group_type: str = 'rotation', num_layers: int = 12, num_rotations: int = 4)[source]
Bases:
ModuleThis class represents a Wide Residual Network (WRN) that is equivariant under rotations or roto-reflections.
The network consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a ReLU activation function. The number of output channels of the convolutional layers is the same for all layers. The input is added to the output of the layer (residual connection).
- class equiadapt.images.canonicalization_networks.escnn_networks.ESCNNWideBasic(in_type: FieldType, middle_type: FieldType, out_type: FieldType, kernel_size: int = 3)[source]
Bases:
EquivariantModuleThis class represents a wide basic layer for an Equivariant Convolutional Neural Network (Equivariant CNN).
The layer consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a ReLU activation function. The number of output channels of the convolutional layers is the same for all layers. The input is added to the output of the layer (residual connection).
- class equiadapt.images.canonicalization_networks.escnn_networks.ESCNNWideBottleneck(in_type: FieldType, middle_type: FieldType, out_type: FieldType, kernel_size: int = 3)[source]
Bases:
EquivariantModuleThis class represents a wide bottleneck layer for an Equivariant Convolutional Neural Network (Equivariant CNN).
The layer consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a ReLU activation function. The number of output channels of the convolutional layers is the same for all layers. The input is added to the output of the layer (residual connection).
Module contents
- class equiadapt.images.canonicalization_networks.ConvNetwork(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a convolutional neural network.
The network consists of a sequence of convolutional layers, each followed by batch normalization and a GELU activation function. The number of output channels of the convolutional layers increases after every third layer. The network ends with a fully connected layer.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the network.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the network. It has the shape (batch_size, out_vector_size).
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.CustomEquivariantNetwork(in_shape: Tuple[int, int, int, int], out_channels: int, kernel_size: int, group_type: str = 'rotation', num_rotations: int = 4, num_layers: int = 1, device: str = 'cpu')[source]
Bases:
ModuleThis class represents a custom equivariant network.
The network is equivariant to a specified group, which can be either the rotation group or the roto-reflection group. The network consists of a sequence of equivariant convolutional layers, each followed by a ReLU activation function.
- class equiadapt.images.canonicalization_networks.ESCNNEquivariantNetwork(in_shape: tuple, out_channels: int, kernel_size: int, group_type: str = 'rotation', num_rotations: int = 4, num_layers: int = 1)[source]
Bases:
ModuleThis class represents an Equivariant Convolutional Neural Network (Equivariant CNN).
The network is equivariant to a group of transformations, which can be either rotations or roto-reflections. The network consists of a sequence of equivariant convolutional layers, each followed by batch normalization, a ReLU activation function, and dropout. The number of output channels of the convolutional layers is the same for all layers.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the network.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the network. It has the shape (batch_size, num_group_elements).
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.ESCNNSteerableNetwork(in_shape: tuple, out_channels: int, kernel_size: int = 9, group_type: str = 'rotation', num_layers: int = 1)[source]
Bases:
ModuleThis class represents a Steerable Equivariant Convolutional Neural Network (Equivariant CNN).
The network is equivariant under all planar rotations. The network consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a FourierELU activation function. The number of output channels of the convolutional layers is the same for all layers.
- class equiadapt.images.canonicalization_networks.ESCNNWRNEquivariantNetwork(in_shape: tuple, out_channels: int = 64, kernel_size: int = 9, group_type: str = 'rotation', num_layers: int = 12, num_rotations: int = 4)[source]
Bases:
ModuleThis class represents a Wide Residual Network (WRN) that is equivariant under rotations or roto-reflections.
The network consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a ReLU activation function. The number of output channels of the convolutional layers is the same for all layers. The input is added to the output of the layer (residual connection).
- class equiadapt.images.canonicalization_networks.ESCNNWideBasic(in_type: FieldType, middle_type: FieldType, out_type: FieldType, kernel_size: int = 3)[source]
Bases:
EquivariantModuleThis class represents a wide basic layer for an Equivariant Convolutional Neural Network (Equivariant CNN).
The layer consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a ReLU activation function. The number of output channels of the convolutional layers is the same for all layers. The input is added to the output of the layer (residual connection).
- class equiadapt.images.canonicalization_networks.ESCNNWideBottleneck(in_type: FieldType, middle_type: FieldType, out_type: FieldType, kernel_size: int = 3)[source]
Bases:
EquivariantModuleThis class represents a wide bottleneck layer for an Equivariant Convolutional Neural Network (Equivariant CNN).
The layer consists of a sequence of equivariant convolutional layers, each followed by batch normalization and a ReLU activation function. The number of output channels of the convolutional layers is the same for all layers. The input is added to the output of the layer (residual connection).
- class equiadapt.images.canonicalization_networks.ResNet18Network(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a neural network based on the ResNet-18 architecture.
The network uses a pre-trained ResNet-18 model without its weights. The final fully connected layer of the ResNet-18 model is replaced with a new fully connected layer.
- resnet18
The ResNet-18 model.
- Type:
torchvision.models.ResNet
- class equiadapt.images.canonicalization_networks.RotationEquivariantConv(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a rotation equivariant convolutional layer.
The layer is equivariant to a group of rotations. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- get_rotated_permuted_weights()[source]
Returns the weights of the layer after rotation and permutation.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, num_rotations, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_rotations, height, width).
- Return type:
torch.Tensor
- get_rotated_permuted_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation and permutation.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation and permutation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.RotationEquivariantConvLift(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a rotation equivariant convolutional layer with lifting.
The layer is equivariant to a group of rotations. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_rotations, height, width).
- Return type:
torch.Tensor
- get_rotated_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.RotoReflectionEquivariantConv(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a roto-reflection equivariant convolutional layer.
The layer is equivariant to a group of rotations and reflections. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- get_rotoreflected_permuted_weights()[source]
Returns the weights of the layer after rotation, reflection, and permutation.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, num_group_elements, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_group_elements, height, width).
- Return type:
torch.Tensor
- get_rotoreflected_permuted_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation, reflection, and permutation.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation, reflection, and permutation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.RotoReflectionEquivariantConvLift(in_channels: int, out_channels: int, kernel_size: int, num_rotations: int = 4, stride: int = 1, padding: int = 0, bias: bool = True, device: str = 'cuda')[source]
Bases:
ModuleThis class represents a roto-reflection equivariant convolutional layer with lifting.
The layer is equivariant to a group of rotations and reflections. The weights of the layer are initialized using the Kaiming uniform initialization method. The layer supports optional bias.
- get_rotoreflected_weights()[source]
Returns the weights of the layer after rotation, reflection, and permutation.
- forward(x: Tensor) Tensor[source]
Performs a forward pass through the layer.
- Parameters:
x (torch.Tensor) – The input data. It should have the shape (batch_size, in_channels, height, width).
- Returns:
The output of the layer. It has the shape (batch_size, out_channels, num_group_elements, height, width).
- Return type:
torch.Tensor
- get_rotoreflected_weights(weights: Tensor, num_rotations: int = 4) Tensor[source]
Returns the weights of the layer after rotation and reflection.
- Parameters:
weights (torch.Tensor) – The weights of the layer.
num_rotations (int, optional) – The number of rotations in the group. Defaults to 4.
- Returns:
The weights after rotation, reflection, and permutation.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization_networks.WideResNet101Network(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a neural network based on the WideResNetNetwork architecture.
The network uses a pre-trained WideResNet model. The final fully connected layer of the WideResNet101 model is replaced with a new fully connected layer.
- resnet18
The ResNet-18 model.
- Type:
torchvision.models.ResNet
- class equiadapt.images.canonicalization_networks.WideResNet50Network(in_shape: tuple, out_channels: int, kernel_size: int, num_layers: int = 2, out_vector_size: int = 128)[source]
Bases:
ModuleThis class represents a neural network based on the WideResNetNetwork architecture.
The network uses a pre-trained WideResNet model. The final fully connected layer of the WideResNet50 model is replaced with a new fully connected layer.
- resnet18
The ResNet-18 model.
- Type:
torchvision.models.ResNet