to_multiscale#
- class deepinv.physics.to_multiscale(physics, img_size, factors=(2, 4, 8), device='cpu', dtype=None)[source]#
Bases:
Convert a single-scale physics operator to a multi-scale physics operator
A single-scale physics operator \(\forw{\cdot}\) can be converted to a multi-scale physics operator, i.e., one operating at multiple coarser scales in addition to the original fine scale.
A downsampled physics operator \(A_j\) operating at scale index \(j \geq 0\) can be evaluated by first upsampling the coarse scale input \(x_j\) to the original fine scale and then applying the original physics operator
\[A_j\left(x\right) = A\left(U_j\left(x_j\right)\right)\]where \(U_j\) denotes upsampling by a factor \(\alpha_j\) associated to the scale index \(j\). For more details, see [1].
Note
The scale index \(j\) is often associated to the scale factor \(\alpha_j = 2^j\).
For linear physics operators, the adjoint operator can be computed from the adjoint of the original physics operator and the adjoint of the upsampling operator, which is the corresponding downsampling operator.
In certain cases, it is possible to evaluate the downsampled physics operator without first upsampling the input image at the original scale. For instance, for blur and inpainting operators, it is possible to compute the downsampled blur kernels and inpainting masks acting directly on the coarse input.
Note
In addition to the generic implementation
MultiScalerPhysicswhich is compatible with arbitrary physics operators, specific implementations cover linear physics operatorsLinearPhysicsMultiScalerand specific physics operators such asBlurMultiScaler,BlurFFTMultiScaler, andInpaintingMultiScaler. Users are encouraged to write custom implementations for physics operators that do not have an efficient implementation yet.Note
The function
to_multiscaleis currently only compatible with 2D input images.- Parameters:
physics (Physics) – single-scale physics that should be made multi-scale
factors (tuple[int, ...]) – coarse scales associated to coarse scale indices, default: (2, 4, 8)
device (torch.device, str) – device of the inputs, default: ‘cpu’
dtype (torch.dtype, None) – dtype of the inputs, default: None
- Returns:
(PhysicsMultiScaler) the multi-scale physics operator
- References: