escnn.kernels
This subpackage implements the complete analytical solutions of the equivariance constraints on the kernel space as explained in A Program to Build E(N)-Equivariant Steerable CNNs. The bases of equivariant kernels should be built through factory functions.
Typically, the user does not need to interact directly with this subpackage. Instead, we suggest to use the interface provided in escnn.gspaces.
This subpackage depends only on escnn.group.
Warning
This module has been largely refactored in version 1.0.0 and is not compatible with previous versions of the library. The interface of the other modules in not affected but some of the generated bases might be slightly different (e.g. basis elements being indexed in a different order). That means the weights trained using an older version of the library might not be compatible with newer instantiations of your models. For backward compatibility, we recommend using version 0.1.9 of the library.
Finally, note that a KernelBasis
is a subclass of torch.nn.Module
.
As such, a KernelBasis
can be treated as a PyTorch’s module, e.g. it can be moved to a CUDA
enable device, the floating point precision of its parameters and buffers can be changed and its forward pass is
generally differentiable.
Warning
Because non-zero circular and spherical harmonics are not well defined at the origin, the gradients of
CircularShellsBasis
and SphericalShellsBasis
are difficult to compute.
In 2D, the gradient at the origin of CircularShellsBasis
is always zero (this could be solved
in the most recent PyTorch versions by leveraging some complex powers).
Instead, in 3D, SphericalShellsBasis
should be able to compute reasonable estimates.
Contents
Generic Kernel Bases
KernelBasis
- class KernelBasis(dim, shape)[source]
Bases:
torch.nn.modules.module.Module
,abc.ABC
Abstract class for implementing the basis of a kernel space. A kernel space is the space of functions in the form:
\[\mathcal{K} := \{ \kappa: X \to \mathbb{R}^{c_\text{out} \times c_\text{in}} \}\]where \(X\) is the base space on which the kernel is defined. For instance, for planar images \(X = \R^2\).
One can also access the dimensionality
dim
of this basis via thelen()
method.- Parameters
- Variables
- abstract sample(points, out=None)[source]
Sample the continuous basis elements on discrete points in
points
. Optionally, store the resulting multidimentional array inout
.points
must be an array of shape (N, D), where D is the dimensionality of the (parametrization of the) base space while N is the number of points.
AdjointBasis
- class AdjointBasis(basis, adjoint)[source]
Bases:
escnn.kernels.basis.KernelBasis
Transform the input
basis
by applying a change of basisadjoint
on the points before sampling the basis.- Parameters
basis (KernelBasis) – a kernel basis
adjoint (ndarray) – an orthonormal matrix defining the change of basis on the base space
UnionBasis
- class UnionBasis(bases_list)[source]
Bases:
escnn.kernels.basis.KernelBasis
Construct the union of a list of bases. All bases must have the same
shape
; the resulting basis hasdim
equal to the sum of the dimensionalities of the individual bases.
EmptyBasisException
- class EmptyBasisException[source]
Exception raised when a
KernelBasis
with no elements is built.
General Steerable Basis for equivariant kernels
The following classes implement the logic behind the kernel constraint solutions described in
A Program to Build E(N)-Equivariant Steerable CNNs.
SteerableKernelBasis
solves the kernel constraint for a generic group and any pair of input and
output representations by decomposing them into irreducible representations and, then, solving the simpler constraints
on irreps independently, as described in General E(2)-Equivariant Steerable CNNs .
IrrepBasis
provides an interface for the methods which solve the kernel constraint for irreps.
We implement two such methods, WignerEckartBasis
and
RestrictedWignerEckartBasis
.
SteerableKernelBasis
- class SteerableKernelBasis(basis, in_repr, out_repr, irreps_basis, **kwargs)[source]
Bases:
escnn.kernels.basis.KernelBasis
Implements a general basis for the vector space of equivariant kernels over an Euclidean space \(X=\R^n\). A \(G\)-equivariant kernel \(\kappa\), mapping between an input field, transforming under \(\rho_\text{in}\) (
in_repr
), and an output field, transforming under \(\rho_\text{out}\) (out_repr
), satisfies the following constraint:\[\kappa(gx) = \rho_\text{out}(g) \kappa(x) \rho_\text{in}(g)^{-1} \qquad \forall g \in G, \forall x \in X\]As the kernel constraint is a linear constraint, the space of equivariant kernels is a vector subspace of the space of all convolutional kernels. It follows that any equivariant kernel can be expressed in terms of a basis of this space.
This class solves the kernel constraint for two arbitrary representations by combining the solutions of the kernel constraints associated to their
IrreducibleRepresentation
s. In order to do so, it relies onirreps_basis
which solves individual irreps constraints.irreps_basis
must be a class (subclass ofIrrepsBasis
) which builds a basis for equivariant kernels associated with irreducible representations when instantiated.The groups \(G\) which are currently implemented are origin-preserving isometries (what are called structure groups, or sometimes gauge groups, in the language of Gauge Equivariant CNNs ). The origin-preserving isometries of \(\R^d\) are subgroups of \(O(d)\), i.e. reflections and rotations. Therefore, equivariance does not enforce any constraint on the radial component of the kernels. Hence, this class only implements a basis for the angular part of the kernels.
Warning
Typically, the user does not need to manually instantiate this class. Instead, we suggest to use the interface provided in escnn.gspaces.
- Parameters
basis (SteerableFiltersBasis) – a steerable basis for scalar filters over the base space
in_repr (Representation) – Representation associated with the input feature field
out_repr (Representation) – Representation associated with the output feature field
irreps_basis (class) – class defining the irreps basis. This class is instantiated for each pair of irreps to solve all irreps constraints.
**kwargs – additional arguments used when instantiating
irreps_basis
- Variables
~.group (Group) – the equivariance group
G
.~.in_repr (Representation) – the input representation
~.out_repr (Representation) – the output representation
- dim_harmonic(j)[source]
Number of kernel basis elements generated from elements of the steerable filter basis (
self.basis
) which transform according to theself.basis.group
-irrep identified byj
.
- compute_harmonics(points)[source]
Pre-compute the sampled steerable filter basis over a set of point. This is an alias for
self.basis.sample_as_dict(points)
.
- sample(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points in
points
. Optionally, store the resulting multidimentional array inout
.points
must be an array of shape (N, d), where N is the number of points.
- sample_harmonics(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points. Rather than using the points’ coordinates, the method directly takes in input the steerable basis elements sampled on this points using the method
escnn.kernels.SteerableKernelBasis.compute_harmonics()
.Similarly, rather than returning a single tensor containing all sampled basis elements, it groups basis elements by the
G
-irrep acting on them. The method returns a dictionary mapping each irrep’sid
to a tensor of shape (N, m, o, i), where N is the number of points, m is the multiplicity of the irrep (seedim_harmonic()
) and o, i is the number of input and output channels (see theshape
attribute).Optionally, store the resulting tensors in
out
, rather than allocating new memory.
IrrepBasis
- class IrrepBasis(basis, in_irrep, out_irrep, dim, harmonics=None)[source]
Bases:
escnn.kernels.basis.KernelBasis
Abstract class for bases implementing the kernel constraint solutions associated to irreducible input and output representations.
Note
The steerable filter
basis
is not necessarily associated with the same group asin_irrep
andout_irrep
. For instance,RestrictedWignerEckartBasis
uses a larger group to definebasis
. The attributeIrrepBasis.group
, instead, refers to the equivariance group of this steerable kernel basis and is the same group ofin_irrep
andout_irrep
. The irreps in the listharmonics
refer to the group in the steerable filterbasis
, and not toIrrepBasis.group
.- Parameters
basis (SteerableFiltersBasis) – the steerable basis used to parameterize scalar filters and generate the kernel solutions
in_irrep (IrreducibleRepresentation) – the input irrep
out_irrep (IrreducibleRepresentation) – the output irrep
dim (int) – the number of elements in the basis
harmonics (list, optional) – optionally, use only a subset of the steerable filters in
basis
. This list defines a subset of the group’s irreps and is used to select only the steerable basis filters which transform according to these irreps.
- Variables
~.group (Group) – the equivariance group
~.in_irrep (IrreducibleRepresentation) – the input irrep
~.out_irrep (IrreducibleRepresentation) – the output irrep
~.basis (SteerableFiltersBasis) – the steerable basis used to parameterize scalar filters
- sample(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points in
points
. Optionally, store the resulting multidimentional array inout
.points
must be an array of shape (N, d), where N is the number of points and d is the dimensionality of the Euclidean space where filters are defined.
- abstract sample_harmonics(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points. Rather than using the points’ coordinates, the method directly takes in input the steerable basis elements sampled on this points using the method
escnn.kernels.SteerableFilterBasis.sample_as_dict()
ofself.basis
.Similarly, rather than returning a single tensor containing all sampled basis elements, it groups basis elements by the
G
-irrep acting on them. The method returns a dictionary mapping each irrep’sid
to a tensor of shape (N, m, o, i), where N is the number of points, m is the multiplicity of the irrep (seedim_harmonic()
) and o, i is the number of input and output channels (see theshape
attribute).Optionally, store the resulting tensors in
out
, rather than allocating new memory.
WignerEckartBasis
- class WignerEckartBasis(basis, in_irrep, out_irrep)[source]
Bases:
escnn.kernels.steerable_basis.IrrepBasis
Solves the kernel constraint for a pair of input and output \(G\)-irreps by using the Wigner-Eckart theorem described in Theorem 2.1 of A Program to Build E(N)-Equivariant Steerable CNNs (see also A Wigner-Eckart Theorem for Group Equivariant Convolution Kernels ). The method relies on a \(G\)-Steerable basis of scalar functions over the base space.
- Parameters
basis (SteerableFiltersBasis) – a G-steerable basis for scalar functions over the base space
in_repr (IrreducibleRepresentation) – the input irrep
out_repr (IrreducibleRepresentation) – the output irrep
RestrictedWignerEckartBasis
- class RestrictedWignerEckartBasis(basis, sg_id, in_irrep, out_irrep)[source]
Bases:
escnn.kernels.steerable_basis.IrrepBasis
Solves the kernel constraint for a pair of input and output \(G\)-irreps by using the Wigner-Eckart theorem described in Theorem 2.1 of A Program to Build E(N)-Equivariant Steerable CNNs. This method implicitly constructs the required \(G\)-steerable basis for scalar functions on the base space from a \(G'\)-steerable basis, with \(G' > G\) a larger group, according to Equation 5 from the same paper.
The equivariance group \(G < G'\) is identified by the input id
sg_id
.Warning
Note that the group \(G'\) associated with
basis
is generally not the same as the group \(G\) associated within_irrep
andout_irrep
and which the resulting kernel basis is equivariant to.- Parameters
basis (SteerableFiltersBasis) – \(G'\)-steerable basis for scalar filters
sg_id (tuple) – id of \(G\) as a subgroup of \(G'\).
in_repr (IrreducibleRepresentation) – the input G-irrep
out_repr (IrreducibleRepresentation) – the output G-irrep
Steerable Filter Bases
To solve the kernel constraint and generate a SteerableKernelBasis
, one requires a steerable
basis for scalar filters over the base space, as derived in
A Program to Build E(N)-Equivariant Steerable CNNs.
Different implementations and parameterizations of steerable convolutions effectively differ by the choice of steerable
filter basis.
The following classes implement different choices of SteerableFilterBasis
.
SteerableFiltersBasis
- class SteerableFiltersBasis(G, action, js)[source]
Bases:
escnn.kernels.basis.KernelBasis
Abstract class for bases implementing a \(G\)-steerable basis for scalar filters over an Euclidean space \(\R^n\).
The action of
G
on the Euclidean space is given by theRepresentation
action
. The dimensionality of the Euclidean space is inferred by the size of theaction
.A \(G\)-steerable basis provides an irreps-decomposition of the action of \(G\) on the vector space of square-integrable functions, i.e. \(L^2(\R^n)\). The input list
js
defines the order and the multiplicity of theG
-irreps in this decomposition. More precisely,js
is a list of tuples(irrep_id, multiplicity)
, whereirrep_id
is theid
of anIrreducibleRepresentation
.The order of the basis elements sampled in
sample()
should be consistent with the order of the irreps in the listjs
.Since this class only parameterizes scalar filters,
SteerableFiltersBasis.shape = (1, 1)
.- Parameters
G (Group) – the symmetry group
action (Representation) – the representation of the action of
G
on the Euclidean spacejs (list) – the multiplicity of each irrep in this basis.
- Variables
~.G (Group) – the symmetry group
~.action (Representation) – the representation of the action of
G
on the Euclidean space~.js (list) – the multiplicity of each irrep in this basis.
- property dimensionality: int
The dimensionality of the Euclidean space on which the scalar filters are defined.
- abstract sample(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points in
points
. Optionally, store the resulting multidimensional array inout
.points
must be an array of shape (N, d), where N is the number of points and d is equal todimensionality()
.
- sample_as_dict(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points in
points
.Rather than returning a single tensor containing all sampled basis elements, it groups basis elements by the
G
-irrep acting on them. Then, the method returns a dictionary mapping each irrep’sid
to a tensor of shape (N, m, d), where m is the multiplicity of the irrep (as in the listjs
) and d is the size of the irrep.points
must be an array of shape (N, D), where N is the number of points and D is equal todimensionality()
.Optionally, store the resulting multidimentional array in
out
.
PointBasis
- class PointBasis(G)[source]
Bases:
escnn.kernels.steerable_filters_basis.SteerableFiltersBasis
Basis for scalar functions over a “0-dimensional” Euclidean space, i.e. a space containing only a single point. This basis only contains the function associating the value \(1\) to this single point.
This basis is steerable for any group
G
, which acts on this point by mapping it to itself.This class is useful to parameterize equivairant linear layers as a special case of steerable convolution layers in a neural network.
Warning
This class is implemented by using
G.trivial_representation
asaction
which, however, implies a 1-dimensional Euclidean space.
CircularShellsBasis
- class CircularShellsBasis(L, radial, filter=None, axis=1.5707963267948966)[source]
Bases:
escnn.kernels.steerable_filters_basis.SteerableFiltersBasis
Build the tensor product basis of a radial profile basis and a circular harmonics basis for kernels over the Euclidean space \(\R^2\).
The kernel space is spanned by an independent basis for each shell. The kernel space each shell is spanned by the circular harmonics of frequency up to L (an independent copy of each for each cell).
Given the bases \(A = \{a_j\}_j\) for the circular shells and \(D = \{d_r\}_r\) for the radial component (indexed by \(r \geq 0\), the radius different rings), this basis is defined as
\[C = \left\{c_{i,j}(\bold{p}) := d_r(||\bold{p}||) a_j(\hat{\bold{p}}) \right\}_{r, j}\]where \((||\bold{p}||, \hat{\bold{p}})\) are the polar coordinates of the point \(\bold{p} \in \R^n\).
The radial component is parametrized using
GaussianRadialProfile
.- Parameters
L (int) – the maximum circular frequency
radial (GaussianRadialProfile) – the basis for the radial profile
filter (callable, optional) – function used to filter out some basis elements. It takes as input a dict describing a basis element and should return a boolean value indicating whether to keep (True) or discard (False) the element. By default (None), all basis elements are kept.
- Variables
~.radial (GaussianRadialProfile) – the radial basis
~.L (int) – the maximum circular frequency
- sample(points, out=None)[source]
Sample the continuous basis elements on a discrete set of
points
in the space \(\R^n\). Optionally, store the resulting multidimensional array inout
.points
must be an array of shape (N, 2) containing N points in the space. Note that the points are specified in cartesian coordinates \((x, y, z, ...)\).
SphericalShellsBasis
- class SphericalShellsBasis(L, radial, filter=None)[source]
Bases:
escnn.kernels.steerable_filters_basis.SteerableFiltersBasis
Build the tensor product basis of a radial profile basis and a spherical harmonics basis for kernels over the Euclidean space \(\R^3\).
The kernel space is spanned by an independent basis for each shell. The kernel space over each shell is spanned by the spherical harmonics of frequency up to L (an independent copy of each for each cell).
Given the bases \(A = \{a_j\}_j\) for the spherical shells and \(D = \{d_r\}_r\) for the radial component (indexed by \(r \geq 0\), the radius of each ring), this basis is defined as
\[C = \left\{c_{i,j}(\bold{p}) := d_r(||\bold{p}||) a_j(\hat{\bold{p}}) \right\}_{r, j}\]where \((||\bold{p}||, \hat{\bold{p}})\) are the polar coordinates of the point \(\bold{p} \in \R^n\).
The radial component is parametrized using
GaussianRadialProfile
.- Parameters
L (int) – the maximum spherical frequency
radial (GaussianRadialProfile) – the basis for the radial profile
filter (callable, optional) – function used to filter out some basis elements. It takes as input a dict describing a basis element and should return a boolean value indicating whether to keep (True) or discard (False) the element. By default (None), all basis elements are kept.
- Variables
~.radial (GaussianRadialProfile) – the radial basis
~.L (int) – the maximum spherical frequency
- sample(points, out=None)[source]
Sample the continuous basis elements on a discrete set of
points
in the space \(\R^n\). Optionally, store the resulting multidimensional array inout
.points
must be an array of shape (N, 3) containing N points in the space. Note that the points are specified in cartesian coordinates \((x, y, z, ...)\).
SparseOrbitBasis
- class SparseOrbitBasis(X, action, root, sigma, harmonics=None, change_of_basis=None, attributes=None)[source]
Bases:
escnn.kernels.steerable_filters_basis.SteerableFiltersBasis
Class which implements a steerable basis for scalar functions on an Euclidean space \(\R^n\) by considering a single orbit of the symmetry group \(G\) in \(\R^n\).
Indeed, an orbit \(\{g.x | g \in G\}\), with \(x \in \R^n\), is isomorphic to an homogeneous space
`X`
of \(G\). A steerable basis for scalar functions over an homogeneous space is given by the harmonic basis inHomSpace
.In this class, a steerable basis over \(\R^n\) is defined by embedding the finite number of points of a finite homogeneous space
`X`
into \(\R^n\) and then “diffusing” the harmonic basis defined over these points in the ambient space using a Gaussian kernel.This class only supports finite homogeneous spaces generated by a finite symmetry group, i.e. not only \(X=G/H\) must have a finite number of elements but also \(G\) itself should.
The embedding of
`X`
into \(\R^n\) is defined via the pointroot
, which defines the embedding of the coset \(eH\) associated with the identity, and theaction
of the group \(G\) on \(\R^n\). This implies that the action of any element of \(H\) should keeproot
fixed.- Parameters
X (HomSpace) – the homogeneous space isomorphic to the orbit in the Euclidean space
action (Representation) – the action of the group
G
on the Euclidean spaceroot (ndarray) – the embedding of the identity coset
sigma (float) – the standard deviation of the Gaussian kernel used to diffuse the harmonic basis in the ambient space.
harmonics (list, optional) – optionally, select only a subset of the harmonic functions. The list should contain the ids of group’s irreps which should be used to construct the harmonic basis. See also
scalar_basis()
.change_of_basis (ndarray, optional) – optionally, apply a transformation on the embedded points to construct a different basis. Equivalently, one can apply this change of basis to both
root
andaction
.attributes (dict, optional) – additional attributes to describe the generated basis.
- Variables
~.X (HomSpace) – the homogeneous space
- sample(points, out=None)[source]
Sample the continuous basis elements on the discrete set of points in
points
. Optionally, store the resulting multidimentional array inout
.points
must be an array of shape (N, d), where N is the number of points and d is thedimensionality()
of the Euclidean space.
SparseOrbitBasisWithIcosahedralSymmetry
- class SparseOrbitBasisWithIcosahedralSymmetry(X, sigma, harmonics=None, change_of_basis=None, attributes=None)[source]
Bases:
escnn.kernels.sparse_basis.SparseOrbitBasis
Given an homogeneous space
X
of the Icosahedral group, builds theSparseOrbitBasis
with aroot
which generates an orbit isomorphic toX
.
GaussianRadialProfile
- class GaussianRadialProfile(radii, sigma)[source]
Bases:
escnn.kernels.basis.KernelBasis
Basis for kernels defined over a radius in \(\R^+_0\).
Each basis element is defined as a Gaussian function. Different basis elements are centered at different radii (
rings
) and can possibly be associated with different widths (sigma
).More precisely, the following basis is implemented:
\[\mathcal{B} = \left\{ b_i (r) := \exp \left( \frac{ \left( r - r_i \right)^2}{2 \sigma_i^2} \right) \right\}_i\]In order to build a complete basis of kernels, you should combine this basis with a basis which defines the angular profile, see for example
SphericalShellsBasis
orCircularShellsBasis
.- Parameters
Generic Group acting on a single point
- kernels_on_point(in_repr, out_repr)[source]
- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
Bases for Group Actions on the Plane
The following factory functions provide an interface to build the bases for kernels equivariant to groups acting on the two dimensional plane (\(d=2\)). The names of the functions follow this convention kernels_[G]_act_R[d], where \(G\) is the origin-preserving isometry group while \(\R^d\) is the space on which it acts, interpreted as the domain of the kernel \(\kappa: \R^d \to \R^{c_\text{out} \times c_\text{in}}\). In the language of Gauge Equivariant CNNs , the origin-preserving isometry \(G\) is called structure group (or, sometimes, gauge group).
R2 Bases
R2: Reflections
- kernels_Flip_act_R2(in_repr, out_repr, radii, sigma, axis=1.5707963267948966, maximum_frequency=None, adjoint=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to reflections.
in_repr
andout_repr
need to beRepresentation
s ofCyclicGroup
withN=2
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).The parameter
axis
is the angle in radians (with respect to the horizontal axis, rotating counter-clockwise) which defines the reflection axis.The analytical angular solutions of kernel constraints belong to an infinite dimensional space and so can be expressed in terms of infinitely many basis elements. Only a finite subset can however be implemented.
maximum_frequency
defines the maximum frequency of a finite-dimensional bandlimited subspace and is therefore necessary to specify it. Seekernels_CN_act_R2()
for more details.- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
axis (float) – angle defining the reflection axis
maximum_frequency (int) – maximum frequency of the basis
adjoint (ndarray, optional) – instead of specifying a reflection axis, you can pass a 2x2 orthogonal matrix defining a change of basis on the base space
R2: Reflections and Discrete Rotations
- kernels_DN_act_R2(in_repr, out_repr, radii, sigma, axis=1.5707963267948966, maximum_frequency=None, max_offset=None, adjoint=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to reflections and \(N\) discrete rotations, modeled by the group \(D_N\).
in_repr
andout_repr
need to beRepresentation
s ofDihedralGroup
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).The parameter
axis
is the angle in radians (with respect to the horizontal axis, rotating counter-clockwise) which defines the reflection axis for the reflection element of the group.Frequencies also appear in a basis with a period of \(N\), i.e. if the basis contains an element with frequency \(k\), then it also contains an element with frequency \(k + N\). In the analytical solutions shown in Table 12 here, each solution has a parameter \(t\) or \(\hat{t}\).
max_offset
defines the maximum absolute value of these two numbers.Either
maximum_frequency
ormax_offset
must be specified.- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
maximum_frequency (int) – maximum frequency of the basis
max_offset (int) – maximum offset in the frequencies of the basis
axis (float) – angle defining the reflection axis
adjoint (ndarray, optional) – instead of specifying a reflection axis, you can pass a 2x2 orthogonal matrix defining a change of basis on the base space
R2: Reflections and Continuous Rotations
- kernels_O2_act_R2(in_repr, out_repr, radii, sigma, maximum_frequency=None, axis=1.5707963267948966, adjoint=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to reflections and continuous rotations, modeled by the group \(O(2)\).
in_repr
andout_repr
need to beRepresentation
s ofO2
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).Because \(O(2)\) contains all rotations, the reflection element of the group can be associated to any reflection axis. Reflections along other axes can be obtained by composition with rotations. However, a choice of this axis is required to align the basis with respect to the action of the group.
- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
axis (float, optional) – angle of the axis of the reflection element
adjoint (ndarray, optional) – instead of specifying a reflection axis, you can pass a 2x2 orthogonal matrix defining a change of basis on the base space
R2: Trivial Action
- kernels_Trivial_act_R2(in_repr, out_repr, radii, sigma, maximum_frequency=None, filter=None)[source]
Builds a basis for unconstrained convolutional kernels.
This is equivalent to use
kernels_CN_act_R2()
with an instance ofCyclicGroup
withN=1
(the trivial group \(C_1\)).in_repr
andout_repr
need to be associated with an instance ofCyclicGroup
withN=1
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).The analytical angular solutions of kernel constraints belong to an infinite dimensional space and so can be expressed in terms of infinitely many basis elements. Only a finite subset can however be implemented.
maximum_frequency
defines the maximum frequency of a finite-dimensinal bandlimited subspace and is therefore necessary to specify it. Seekernels_CN_act_R2()
for more details.- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
axis (float) – angle defining the reflection axis
maximum_frequency (int) – maximum frequency of the basis
R2: Discrete Rotations
- kernels_CN_act_R2(in_repr, out_repr, radii, sigma, maximum_frequency=None, max_offset=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to \(N\) discrete rotations, modeled by the group \(C_N\).
in_repr
andout_repr
need to beRepresentation
s ofCyclicGroup
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).The analytical angular solutions of kernel constraints belong to an infinite dimensional space and so can be expressed in terms of infinitely many basis elements, each associated with one unique frequency. Because the kernels are then sampled on a finite number of points (e.g. the cells of a grid), only low-frequency solutions needs to be considered. This enables us to build a finite dimensional basis containing only a finite subset of all analytical solutions.
maximum_frequency
is an integer controlling the highest frequency sampled in the basis.Frequencies also appear in a basis with a period of \(N\), i.e. if the basis contains an element with frequency \(k\), then it also contains an element with frequency \(k + N\). In the analytical solutions shown in Table 11 here, each solution has a parameter \(t\) or \(\hat{t}\).
max_offset
defines the maximum absolute value of these two numbers.Either
maximum_frequency
ormax_offset
must be specified.- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
maximum_frequency (int) – maximum frequency of the basis
max_offset (int) – maximum offset in the frequencies of the basis
R2: Continuous Rotations
- kernels_SO2_act_R2(in_repr, out_repr, radii, sigma, maximum_frequency=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to continuous rotations, modeled by the group \(SO(2)\).
in_repr
andout_repr
need to beRepresentation
s ofSO2
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
R2: Generic Subgroups of Continuous Rotations
R2: Generic Subgroups of Continuous Rotations and Reflections
Bases for Group Actions in 3D Space
The following factory functions provide an interface to build the bases for kernels equivariant to groups acting on the three dimensional Euclidean space (\(d=3\)). The names of the functions follow this convention kernels_[G]_act_R[d], where \(G\) is the origin-preserving isometry group while \(\R^d\) is the space on which it acts, interpreted as the domain of the kernel \(\kappa: \R^d \to \R^{c_\text{out} \times c_\text{in}}\). In the language of Gauge Equivariant CNNs , the origin-preserving isometry \(G\) is called structure group (or, sometimes, gauge group).
R3 Bases
R3: Inversions and Continuous Rotations
- kernels_O3_act_R3(in_repr, out_repr, radii, sigma, maximum_frequency=None, adjoint=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to reflections and continuous rotations, modeled by the group \(O(3)\).
in_repr
andout_repr
need to beRepresentation
s ofO3
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).Because \(O(3)\) contains all rotations, the reflection element of the group can be associated to any reflection axis.
- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
adjoint (ndarray, optional) – 3x3 orthogonal matrix defining a change of basis on the base space
R3: Continuous Rotations
- kernels_SO3_act_R3(in_repr, out_repr, radii, sigma, maximum_frequency=None, adjoint=None, filter=None)[source]
Builds a basis for convolutional kernels equivariant to continuous rotations, modeled by the group \(SO(3)\).
in_repr
andout_repr
need to beRepresentation
s ofSO3
.Because the equivariance constraints allow any choice of radial profile, we use a
GaussianRadialProfile
.radii
specifies the radial distances at which the rings are centered whilesigma
contains the width of each of these rings (seeGaussianRadialProfile
).- Parameters
in_repr (Representation) – the representation specifying the transformation of the input feature field
out_repr (Representation) – the representation specifying the transformation of the output feature field
radii (list) – radii of the rings defining the basis for the radial profile
sigma (list or float) – widths of the rings defining the basis for the radial profile
adjoint (ndarray, optional) – 3x3 orthogonal matrix defining a change of basis on the base space