hyri.regulariser.prox_usara#
Implement the uSARA positivity-constrained proximal operator.
This file provides a dual forward-backward proximal step combining weighted
wavelet \(\ell_1\) sparsity with positivity projection. Wavelet transforms
are evaluated with ptwt.
Class
Apply the uSARA proximal operator with positivity constraint. |
- class hyri.regulariser.prox_usara.ProxSARAPos(img_size: tuple[int, int], rank_num_ch: int = 1, rank_ch_start: int = 0, wl_dict: tuple[str, ...] = ('dirac', 'db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 'db8'), dec_lev: int = 4, mode: str = 'zero', sfth_val: Tensor = tensor(1.0000e-04), wl_noise_floor: Tensor = tensor(1.0000e-04), max_iter: int = 20, obj_tol: float = 0.0001, device: device = device(type='cpu'), dtype: dtype = torch.float32, verbose: bool | int = True)#
Bases:
RegulariserApply the uSARA proximal operator with positivity constraint.
This class implements the proximal operator of the positivity-constrained weighted wavelet prior used by uSARA. It extends
Regulariser. For an input image cube \(\mathbf{x}\), it computes \(\operatorname{prox}_{g}(\mathbf{x})\), where\[g(\mathbf{z}) = \iota_{\mathbb{R}_{+}}(\mathbf{z}) + \left\| \mathbf{\Psi}^{\dagger}\mathbf{z} \right\|_{1,\mathbf{w}},\]with \(\iota_{\mathbb{R}_{+}}\) the indicator function of the non-negative orthant, \(\mathbf{\Psi}^{\dagger}\) the concatenated wavelet transform operator, and \(\mathbf{w}\) the weighting coefficients. In this implementation, the weighted \(\ell_{1}\) term is handled by a dual forward-backward iteration, while the primal update enforces positivity.
The wavelet dictionary may include several wavelet bases and an optional Dirac basis. The transforms are evaluated with
ptwt. The weighted \(\ell_{1}\)-norm is evaluated channel-wise, with one set of reweighting coefficients per channel and per wavelet coefficient block.- Shape:
Input –
(1, C, H, W)whereCequalsrank_num_chfor the current rank.Output –
(1, C, H, W)with the same shape as input.
- _dual#
Current dual variables.
- Type:
Example
>>> prox = ProxSARAPos( ... img_size=(32, 32), ... rank_num_ch=2, ... sfth_val=torch.tensor([1e-3, 1e-3]), ... wl_noise_floor=torch.tensor([1e-4, 1e-4]), ... ) >>> x = torch.zeros(1, 2, 32, 32) >>> prox.update(x) >>> y = prox(x) >>> y.shape torch.Size([1, 2, 32, 32])
References
Terris, M., Dabbech, A., Tang, C., & Wiaux, Y. (2023). Image reconstruction algorithms in radio interferometry: From handcrafted to learned regularization denoisers. MNRAS, 518(1), 604-622.
Combettes, P. L., & Pesquet, J.-C. (2011). Proximal splitting methods in signal processing. In H. H. Bauschke, R. S. Burachik, P. L. Combettes, V. Elser, D. R. Luke, & H. Wolkowicz (Eds.), Fixed-point algorithms for inverse problems in science and engineering (pp. 185-212). Springer.
Wolter, M., Blanke, F., Garcke, J., & Hoyt, C. T. (2024). ptwt - The PyTorch Wavelet Toolbox. J. Mach. Learn. Res., 25(80), 1-7.
Initialise the uSARA positivity proximal operator.
- Parameters:
rank_num_ch (int, optional) – Number of channels handled by this rank. Default: 1.
rank_ch_start (int, optional) – Global start index of local channels. Default: 0.
wl_dict (Tuple[str, ...], optional) – Wavelet dictionary including optional
"dirac". Default: (“dirac”, “db1”, “db2”, “db3”, “db4”, “db5”, “db6”, “db7”, “db8”).dec_lev (int, optional) – Wavelet decomposition depth. Default: 4.
mode (str, optional) – Boundary mode for wavelet transforms. Default: “zero”.
sfth_val (torch.Tensor) – Soft-thresholding value per channel. It should have a number of elements equals to the number of channels or equals to 1. Default: torch.tensor(1e-4).
wl_noise_floor (torch.Tensor) – Reweighting noise floor per channel. It should have a number of elements equals to the number of channels or equals to 1. Default: torch.tensor(1e-4).
max_iter (int, optional) – Maximum dual forward-backward iterations. Default: 20.
obj_tol (float, optional) – Relative objective tolerance used for stopping. Default: 1e-4.
device (torch.device, optional) – Execution device. Default: torch.device(“cpu”).
dtype (torch.dtype, optional) – Tensor dtype for computation. Default: torch.float.
verbose (Union[bool, int], optional) – Verbosity level. Default: True.
- Raises:
AssertionError – If the wavelet dictionary is empty or contains unsupported bases.
AssertionError – If the soft-thresholding value is not a scalar or a vector with one value per channel.
AssertionError – If the noise floor level is not a scalar or a vector with one value per channel.
- _wavedec2_dict(x: Tensor) Tensor#
Pack wavelet coefficients from all bases into one tensor.
- Parameters:
x (torch.Tensor) – Input tensor with shape
(1, C, H, W).- Returns:
Packed coefficient tensor with shape
(1, C, N).- Return type:
- _waverec2_dict(y: Tensor) Tensor#
Reconstruct tensors from packed wavelet coefficients.
- Parameters:
y (torch.Tensor) – Packed coefficient tensor with shape
(1, C, N).- Returns:
Reconstructed tensor with shape
(1, C, H, W).- Return type:
- _prox_l1_adj(z: Tensor, sfth: Tensor) Tensor#
Apply the proximal map of the adjoint \(\ell_1\) norm.
- Parameters:
z (torch.Tensor) – Input coefficient tensor.
sfth (torch.Tensor) – Soft-thresholding levels.
- Returns:
Thresholded coefficients.
- Return type:
- __call__(x: Tensor) Tensor#
Run the uSARA proximal step.
- Parameters:
x (torch.Tensor) – Input tensor with shape
(1, C, H, W).- Returns:
Positivity-constrained proximal output.
- Return type:
Note
This method runs a dual forward-backward loop that alternates primal positivity projection and weighted wavelet soft thresholding.
- update(x: Tensor) None#
Update per-coefficient reweighting factors.
- Parameters:
x (torch.Tensor) – Input tensor used to recompute SARA weights.
Note
Reweighting is computed independently for each wavelet basis and, when enabled, for the Dirac component.
- get_l1_norm() float#
Return the latest weighted \(\ell_1\) norm value.
- Returns:
Last objective regularisation term.
- Return type:
- set_noise_floor_level(wl_noise_floor: Tensor) None#
Set the wavelet reweighting noise floor.
- Parameters:
wl_noise_floor (torch.Tensor) – Per-channel noise-floor in the wavelet coefficients.
- Raises:
AssertionError – If the noise floor level is not a scalar or a vector with one value per channel.
- set_soft_thresholding_value(sfth_val: Tensor) None#
Set wavelet soft-thresholding levels.
- Parameters:
sfth_val (torch.Tensor) – Per-channel threshold tensor.
- Raises:
AssertionError – If the soft-thresholding value is not a scalar or a vector with one value per channel.