neuralop.layers.discrete_continuous_convolution
.DiscreteContinuousConvTranspose2d
- class neuralop.layers.discrete_continuous_convolution.DiscreteContinuousConvTranspose2d(in_channels: int, out_channels: int, grid_in: Tensor, grid_out: Tensor, kernel_shape: int | List[int], basis_type: str = 'piecewise_linear', n_in: Tuple[int] | None = None, n_out: Tuple[int] | None = None, quadrature_weights: Tensor | None = None, periodic: bool | None = False, groups: int | None = 1, bias: bool | None = True, radius_cutoff: float | None = None)[source]
Transpose variant of discrete-continuous convolutions on arbitrary 2d grids as implemented for [1]. Forward call expects an input of shape (batch_size, in_channels, n_in).
- Parameters:
- in_channels: int
input channels to DISCO convolution
- out_channels: int
output channels of DISCO convolution
- grid_in: torch.Tensor or literal ``{‘equidistant’, ‘legendre-gauss’, ‘equiangular’, ‘lobatto’}``
input grid in the form of a point cloud of shape (n_in, 2). Can also pass a string to generate a regular (tensor) grid. For exact options see
torch_harmonics.quadrature
.- grid_out: torch.Tensor or literal ``{‘equidistant’, ‘legendre-gauss’, ‘equiangular’, ‘lobatto’}``
output grid in the form of a point cloud (n_out, 2). Can also pass a string to generate a regular (tensor) grid. For exact options see
torch_harmonics.quadrature
.- kernel_shape
Union[int, List[int]]
Dimensions of the convolution kernel, either one int or a two-int tuple. * If one int k, the kernel will be a square of shape (k,k), meaning the convolution will be ‘isotropic’: both directions are equally scaled in feature space.
If two ints (k1,k2), the kernel will be a rectangle of shape (k1,k2), meaning the convolution
will be ‘anisotropic’: one direction will be compressed or stretched in feature space.
- basis_type: str literal ``{‘piecewise_linear’, ‘morlet’, ‘zernike’}``
choice of basis functions to use for convolution filter tensor.
- n_in: Tuple[int], optional
number of input points along each dimension. Only used if grid_in is passed as a str. See
torch_harmonics.quadrature
.- n_out: Tuple[int], optional
number of output points along each dimension. Only used if grid_out is passed as a str. See
torch_harmonics.quadrature
.- quadrature_weights: torch.Tensor, optional
quadrature weights on the input grid expects a tensor of shape (n_in,)
- periodic: bool, optional
whether the domain is periodic, by default False
- groups: int, optional
number of groups in the convolution, by default 1
- bias: bool, optional
whether to use a bias, by default True
- radius_cutoff: float, optional
cutoff radius for the kernel. For a point
x
on the input grid, every pointy
on the output grid with||x - y|| <= radius_cutoff
will be affected by the value atx
. By default, set to 2 / sqrt(# of output points)
Methods
forward
(x)Forward call.
Returns the precomputed local convolution filter matrix Psi.
References
[1]Liu-Schiaffini M., Berner J., Bonev B., Kurth T., Azizzadenesheli K., Anandkumar A.; Neural Operators with Localized Integral and Differential Kernels; arxiv:2402.16845
- get_local_filter_matrix()[source]
Returns the precomputed local convolution filter matrix Psi. Psi parameterizes the kernel function as triangular basis functions evaluated on pairs of points on the convolution’s input and output grids, such that Psi[l, i, j] is the l-th basis function evaluated on point i in the output grid and point j in the input grid.
- forward(x: Tensor) Tensor [source]
Forward call. Expects an input of shape batch_size x in_channels x n_in.