Modules¤
We provide linear Clifford layers; 1D, 2D, 3D Clifford convolution layers, and 2D, 3D Clifford Fourier transform layers. Additionally, Clifford normalization schemes are provided.
All these modules are available for different algebras.
CliffordLinear
¤
Bases: Module
Clifford linear layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g |
Union[List, Tuple]
|
Clifford signature tensor. |
required |
in_channels |
int
|
Number of input channels. |
required |
out_channels |
int
|
Number of output channels. |
required |
bias |
bool
|
If True, adds a learnable bias to the output. Defaults to True. |
True
|
Source code in cliffordlayers/nn/modules/cliffordlinear.py
CliffordConv1d
¤
Bases: _CliffordConvNd
1d Clifford convolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g |
Union[tuple, list, Tensor]
|
Clifford signature. |
required |
in_channels |
int
|
Number of channels in the input tensor. |
required |
out_channels |
int
|
Number of channels produced by the convolution. |
required |
kernel_size |
int
|
Size of the convolving kernel. |
3
|
stride |
int
|
Stride of the convolution. |
1
|
padding |
int
|
padding added to both sides of the input. |
0
|
dilation |
int
|
Spacing between kernel elements. |
1
|
groups |
int
|
Number of blocked connections from input channels to output channels. |
1
|
bias |
bool
|
If True, adds a learnable bias to the output. |
True
|
padding_mode |
str
|
Padding to use. |
'zeros'
|
Source code in cliffordlayers/nn/modules/cliffordconv.py
CliffordConv2d
¤
Bases: _CliffordConvNd
2d Clifford convolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g |
Union[tuple, list, Tensor]
|
Clifford signature. |
required |
in_channels |
int
|
Number of channels in the input tensor. |
required |
out_channels |
int
|
Number of channels produced by the convolution. |
required |
kernel_size |
Union[int, Tuple[int, int]]
|
Size of the convolving kernel. |
3
|
stride |
Union[int, Tuple[int, int]]
|
Stride of the convolution. |
1
|
padding |
Union[int, Tuple[int, int]]
|
padding added to both sides of the input. |
0
|
dilation |
Union[int, Tuple[int, int]]
|
Spacing between kernel elements. |
1
|
groups |
int
|
Number of blocked connections from input channels to output channels. |
1
|
bias |
bool
|
If True, adds a learnable bias to the output. |
True
|
padding_mode |
str
|
Padding to use. |
'zeros'
|
rotation |
bool
|
If True, enables the rotation kernel for Clifford convolution. |
False
|
Source code in cliffordlayers/nn/modules/cliffordconv.py
CliffordConv3d
¤
Bases: _CliffordConvNd
3d Clifford convolution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g |
Union[tuple, list, Tensor]
|
Clifford signature. |
required |
in_channels |
int
|
Number of channels in the input tensor. |
required |
out_channels |
int
|
Number of channels produced by the convolution. |
required |
kernel_size |
Union[int, Tuple[int, int, int]]
|
Size of the convolving kernel. |
3
|
stride |
Union[int, Tuple[int, int, int]]
|
Stride of the convolution. |
1
|
padding |
Union[int, Tuple[int, int, int]]
|
padding added to all sides of the input. |
0
|
dilation |
Union[int, Tuple[int, int, int]]
|
Spacing between kernel elements. |
1
|
groups |
int
|
Number of blocked connections from input channels to output channels. |
1
|
bias |
bool
|
If True, adds a learnable bias to the output. |
True
|
padding_mode |
str
|
Padding to use. |
'zeros'
|
Source code in cliffordlayers/nn/modules/cliffordconv.py
CliffordSpectralConv2d
¤
Bases: Module
2d Clifford Fourier layer. Performs following three steps: 1. Clifford Fourier transform over the multivector of 2d Clifford algebras, based on complex Fourier transforms using pytorch.fft.fft2. 2. Weight multiplication in the Clifford Fourier space using the geometric product. 3. Inverse Clifford Fourier transform, based on inverse complex Fourier transforms using pytorch.fft.ifft2.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g |
Union[tuple, list, Tensor]
|
Signature of Clifford algebra. |
required |
in_channels |
int
|
Number of input channels. |
required |
out_channels |
int
|
Number of output channels. |
required |
modes1 |
int
|
Number of non-zero Fourier modes in the first dimension. |
required |
modes2 |
int
|
Number of non-zero Fourier modes in the second dimension. |
required |
multiply |
bool
|
Multipliation in the Fourier space. If set to False this class only crops high-frequency modes. |
True
|
Source code in cliffordlayers/nn/modules/cliffordfourier.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
CliffordSpectralConv3d
¤
Bases: Module
3d Clifford Fourier layer. Performs following three steps: 1. Clifford Fourier transform over the multivector of 3d Clifford algebras, based on complex Fourier transforms using pytorch.fft.fftn. 2. Weight multiplication in the Clifford Fourier space using the geometric product. 3. Inverse Clifford Fourier transform, based on inverse complex Fourier transforms using pytorch.fft.ifftn.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g |
Union[tuple, list, Tensor]
|
Signature of Clifford algebra. |
required |
in_channels |
int
|
Number of input channels. |
required |
out_channels |
int
|
Number of output channels. |
required |
modes1 |
int
|
Number of non-zero Fourier modes in the first dimension. |
required |
modes2 |
int
|
Number of non-zero Fourier modes in the second dimension. |
required |
modes3 |
int
|
Number of non-zero Fourier modes in the second dimension. |
required |
multiply |
bool
|
Multipliation in the Fourier space. If set to False this class only crops high-frequency modes. |
True
|
Source code in cliffordlayers/nn/modules/cliffordfourier.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
CliffordG3Conv2d
¤
Bases: _CliffordG3ConvNd
2D convolutional layer where the features are vectors in G3.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_channels |
int
|
Number of input channels. |
required |
out_channels |
int
|
Number of output channels. |
required |
kernel_size |
int
|
Size of the convolutional kernel. Defaults to 1. |
1
|
stride |
int
|
Stride of the convolution operation. Defaults to 1. |
1
|
padding |
int or str
|
Padding added to both sides of the input or padding mode. Defaults to 0. |
0
|
dilation |
int
|
Dilation rate of the kernel. Defaults to 1. |
1
|
groups |
int
|
Number of blocked connections from input channels to output channels. Defaults to 1. |
1
|
bias |
bool
|
If True, adds a bias term to the output. Defaults to False. |
False
|
Source code in cliffordlayers/nn/modules/gcan.py
CliffordG3ConvTranspose2d
¤
Bases: _CliffordG3ConvNd
2D transposed convolutional layer where the features are vectors in G3.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_channels |
int
|
Number of input channels. |
required |
out_channels |
int
|
Number of output channels. |
required |
kernel_size |
int
|
Size of the convolutional kernel. Defaults to 1. |
1
|
stride |
int
|
Stride of the convolution operation. Defaults to 1. |
1
|
padding |
int or str
|
Padding added to both sides of the input or padding mode. Defaults to 0. |
0
|
dilation |
int
|
Dilation rate of the kernel. Defaults to 1. |
1
|
groups |
int
|
Number of blocked connections from input channels to output channels. Defaults to 1. |
1
|
bias |
bool
|
If True, adds a bias term to the output. Defaults to False. |
False
|
Source code in cliffordlayers/nn/modules/gcan.py
CliffordG3GroupNorm
¤
Bases: Module
A module that applies group normalization to vectors in G3.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_groups |
int
|
Number of groups to normalize over. |
required |
num_features |
int
|
Number of features in the input. |
required |
num_blades |
int
|
Number of blades in the input. |
required |
scale_norm |
bool
|
If True, the output is scaled by the norm of the input. Defaults to False. |
False
|
Source code in cliffordlayers/nn/modules/gcan.py
CliffordG3LinearVSiLU
¤
Bases: Module
A module that applies the vector SiLU using a linear combination to vectors in G3.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channels |
int
|
Number of channels in the input. |
required |
Source code in cliffordlayers/nn/modules/gcan.py
CliffordG3MeanVSiLU
¤
Bases: Module
A module that applies the vector SiLU using vector mean to vectors in G3.
Source code in cliffordlayers/nn/modules/gcan.py
CliffordG3SumVSiLU
¤
Bases: Module
A module that applies the vector SiLU using vector sum to vectors in G3.
Source code in cliffordlayers/nn/modules/gcan.py
MultiVectorAct
¤
Bases: Module
A module to apply multivector activations to the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channels |
int
|
Number of channels in the input. |
required |
algebra |
The algebra object that defines the geometric product. |
required | |
input_blades |
(list, tuple)
|
The nonnegative input blades. |
required |
kernel_blades |
(list, tuple)
|
The blades that will be used to compute the activation. Defaults to all input blades. |
None
|
agg |
str
|
The aggregation method to be used. Options include "linear", "sum", and "mean". Defaults to "linear". |
'linear'
|
Source code in cliffordlayers/nn/modules/gcan.py
PGAConjugateLinear
¤
Bases: Module
Linear layer that applies the PGA conjugation to the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_features |
int
|
Number of input features. |
required |
out_features |
int
|
Number of output features. |
required |
algebra |
Algebra
|
Algebra object that defines the geometric product. |
required |
input_blades |
tuple
|
Nonnegative blades of the input multivectors. |
required |
action_blades |
tuple
|
Blades of the action. Defaults to (0, 5, 6, 7, 8, 9, 10, 15), which encodes rotation and translation. |
(0, 5, 6, 7, 8, 9, 10, 15)
|
Source code in cliffordlayers/nn/modules/gcan.py
get_clifford_left_kernel(M, w, flatten=True)
¤
Obtains the matrix that computes the geometric product from the left. When the output is flattened, it can be used to apply a fully connected layer on the multivectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
Tensor
|
Cayley table that defines the geometric relation. |
required |
w |
Tensor
|
Input tensor with shape (o, i, c) where o is the number of output channels, i is the number of input channels, and c is the number of blades. |
required |
flatten |
bool
|
If True, the resulting matrix will be reshaped for subsequent fully connected operations. Defaults to True. |
True
|
Source code in cliffordlayers/nn/modules/gcan.py
get_clifford_right_kernel(M, w, flatten=True)
¤
Obtains the matrix that computes the geometric product from the right. When the output is flattened, it can be used to apply a fully connected layer on the multivectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
Tensor
|
Cayley table that defines the geometric relation. |
required |
w |
Tensor
|
Input tensor with shape (o, i, c) where o is the number of output channels, i is the number of input channels, and c is the number of blades. |
required |
flatten |
bool
|
If True, the resulting matrix will be reshaped for subsequent fully connected operations. Defaults to True. |
True
|
Source code in cliffordlayers/nn/modules/gcan.py
CliffordBatchNorm1d
¤
Bases: _CliffordBatchNorm
Clifford batch normalization for 2D or 3D data.
The input data is expected to be at least 3d, with shape (B, C, D, I)
,
where B
is the batch dimension, C
the channels/features, and D the remaining dimension (if present).
See [torch.nn.BatchNorm1d] for details.
Source code in cliffordlayers/nn/modules/batchnorm.py
CliffordBatchNorm2d
¤
Bases: _CliffordBatchNorm
Clifford batch normalization for 4D data.
The input data is expected to be 4d, with shape (B, C, *D, I)
,
where B
is the batch dimension, C
the channels/features, and D the remaining dimension 2 dimensions.
See torch.nn.BatchNorm2d for details.
Source code in cliffordlayers/nn/modules/batchnorm.py
CliffordBatchNorm3d
¤
Bases: _CliffordBatchNorm
Clifford batch normalization for 5D data.
The input data is expected to be 5d, with shape (B, C, *D, I)
,
where B
is the batch dimension, C
the channels/features, and D the remaining dimension 3 dimensions.
See torch.nn.BatchNorm2d for details.
Source code in cliffordlayers/nn/modules/batchnorm.py
ComplexBatchNorm1d
¤
Bases: _ComplexBatchNorm
Complex-valued batch normalization for 2D or 3D data.
The input complex-valued data is expected to be at least 2d, with shape (B, C, D)
,
where B
is the batch dimension, C
the channels/features, and D the remaining dimension (if present).
See torch.nn.BatchNorm1d for details.
Source code in cliffordlayers/nn/modules/batchnorm.py
ComplexBatchNorm2d
¤
Bases: _ComplexBatchNorm
Complex-valued batch normalization for 4D data.
The input complex-valued data is expected to be 4d, with shape (B, C, *D)
,
where B
is the batch dimension, C
the channels/features, and D the remaining 2 dimensions.
See torch.nn.BatchNorm2d for details.
Source code in cliffordlayers/nn/modules/batchnorm.py
ComplexBatchNorm3d
¤
Bases: _ComplexBatchNorm
Complex-valued batch normalization for 5D data.
The input complex-valued data is expected to be 5d, with shape (B, C, *D)
,
where B
is the batch dimension, C
the channels/features, and D the remaining 3 dimensions.
See torch.nn.BatchNorm3d for details.
Source code in cliffordlayers/nn/modules/batchnorm.py
CliffordGroupNorm1d
¤
Bases: _CliffordGroupNorm
Clifford group normalization for 2D or 3D data.
The input data is expected to be at least 3d, with shape (B, C, D, I)
,
where B
is the batch dimension, C
the channels/features, and D the remaining dimension (if present).
Source code in cliffordlayers/nn/modules/groupnorm.py
CliffordGroupNorm2d
¤
Bases: _CliffordGroupNorm
Clifford group normalization for 4D data.
The input data is expected to be 4D, with shape (B, C, *D, I)
,
where B
is the batch dimension, C
the channels/features, and D the remaining 2 dimensions.
Source code in cliffordlayers/nn/modules/groupnorm.py
CliffordGroupNorm3d
¤
Bases: _CliffordGroupNorm
Clifford group normalization for 4D data.
The input data is expected to be 5D, with shape (B, C, *D, I)
,
where B
is the batch dimension, C
the channels/features, and D the remaining 3 dimensions.
Source code in cliffordlayers/nn/modules/groupnorm.py
ComplexGroupNorm1d
¤
Bases: _ComplexGroupNorm
Complex-valued group normalization for 2D or 3D data.
The input complex-valued data is expected to be at least 2d, with shape (B, C, D)
,
where B
is the batch dimension, C
the channels/features, and D the remaining dimension (if present).
Source code in cliffordlayers/nn/modules/groupnorm.py
ComplexGroupNorm2d
¤
Bases: _ComplexGroupNorm
Complex-valued group normalization for 4 data.
The input complex-valued data is expected to be 4d, with shape (B, C, *D)
,
where B
is the batch dimension, C
the channels/features, and D the remaining 2 dimensions.
Source code in cliffordlayers/nn/modules/groupnorm.py
ComplexGroupNorm3d
¤
Bases: _ComplexGroupNorm
Complex-valued group normalization for 5 data.
The input complex-valued data is expected to be 5d, with shape (B, C, *D)
,
where B
is the batch dimension, C
the channels/features, and D the remaining 3 dimensions.