plenoptic.models.Linear#

Note

This object is a torch.nn.Module. It therefore has all the methods and attributes from that class, even though they are not documented here (to avoid cluttering this page).

class plenoptic.models.Linear(kernel_size=(3, 3), pad_mode='circular', default_filters=True)[source]#

Bases: Module

Simplistic linear convolutional model.

If default_filters=True, this model splits the input image into low and high frequencies.

Parameters:
  • kernel_size (int | tuple[int, int] (default: (3, 3))) – Convolutional kernel size.

  • pad_mode (str (default: 'circular')) – Mode with which to pad image using torch.nn.functional.pad.

  • default_filters (bool (default: True)) – Initialize the filters to a low-pass and a band-pass. If False, filters are randomly initialized.

Raises:

ValueError – If kernel_size is not one or two positive integers.

Examples

>>> import plenoptic as po
>>> linear_model = po.models.Linear()
>>> linear_model
Linear(
  (conv): Conv2d(1, 2, kernel_size=(3, 3), stride=(1, 1), bias=False)
)

To specify the kernel size :

>>> linear_model = po.models.Linear(kernel_size=(5, 5))
>>> linear_model
Linear(
  (conv): Conv2d(1, 2, kernel_size=(5, 5), stride=(1, 1), bias=False)
)

Methods

forward(x)

Convolve filter with input tensor.

forward(x)[source]#

Convolve filter with input tensor.

We use same-padding to ensure that the output and input shapes are matched.

Parameters:

x (Tensor) – The input tensor, with (batch, channel, height, width).

Return type:

Tensor

Returns:

y – A linear convolution of the input image, of same shape as the input.

Examples

>>> import plenoptic as po
>>> linear_model = po.models.Linear()
>>> img = po.data.curie()
>>> y = linear_model.forward(img)
>>> po.plot.imshow(
...     [img, y],
...     title=[
...         "Input image",
...         "Lowpass channel output",
...         "Bandpass channel output",
...     ],
... )
<PyrFigure size...>

(png, hires.png, pdf)

../../_images/plenoptic-models-Linear-1.png