conv2d#
- class deepinv.physics.functional.conv2d(x: Tensor, filter: Tensor, padding: str = 'valid', correlation=False)[source]#
Bases:
A helper function performing the 2d convolution of images
x
andfilter
. The adjoint of this operation isdeepinv.physics.functional.conv_transposed2d()
- Parameters:
x (torch.Tensor) – Image of size
(B, C, W, H)
.filter (torch.Tensor) – Filter of size
(b, c, w, h)
whereb
can be either1
orB
andc
can be either1
orC
. Filter center is at(hh, ww)
wherehh = h//2
if h is odd andhh = h//2 - 1
if h is even. Same forww
.correlation (bool) – choose True if you want a cross-correlation (default False)
- ..note:
Contrarily to Pytorch
torch.functional.conv2d()
, which performs a cross-correlation, this function performs a convolution.
If
b = 1
orc = 1
, then this function supports broadcasting as the same as numpy. Otherwise, each channel of each image is convolved with the corresponding kernel.- Parameters:
padding – (options =
valid
,circular
,replicate
,reflect
,constant
) Ifpadding = 'valid'
the blurred output is smaller than the image (no padding), otherwise the blurred output has the same size as the image.constant
corresponds to zero padding orsame
intorch.nn.functional.conv2d()
- Returns:
(torch.Tensor) : the output