hyri.regulariser.prox_positivity#
Implement a positivity projection regulariser.
This file provides a proximal operator that projects image-domain values onto the non-negative orthant.
Class
Project tensors onto the non-negative orthant. |
- class hyri.regulariser.prox_positivity.ProxOpPositivity(rank_num_ch: int = 1, rank_ch_start: int = 0, device: device = device(type='cpu'), dtype: dtype = torch.float32, verbose: bool = True)#
Bases:
RegulariserProject tensors onto the non-negative orthant.
This regulariser applies an element-wise positivity projection equivalent to ReLU and does not maintain adaptive state across iterations. The operator is \(\operatorname{prox}_{\iota_{\mathbb{R}_{+}}}(x)=\max(x,0)\).
- Shape:
Input – Any tensor shape (for example
(N, C, H, W)).Output – Tensor with the same shape as input, with negative values clipped to zero.
Example
>>> prox = ProxOpPositivity() >>> prox(torch.tensor([[-1.0, 2.0]])) tensor([[0., 2.]])
Initialise the positivity regulariser.
- 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.
device (torch.device, optional) – Execution device. Default: torch.device(“cpu”).
dtype (torch.dtype, optional) – Tensor dtype for computation. Default: torch.float.
verbose (bool, optional) – Enable progress messages. Default: True.
- __call__(x: Tensor) Tensor#
Project an input tensor onto the positivity set.
- Parameters:
x (torch.Tensor) – Input tensor.
- Returns:
Element-wise non-negative tensor with the same shape and dtype as
x.- Return type: