hyri.regulariser.regulariser#
Define the abstract base API for regularisers.
This file provides the shared constructor and minimal interface used by all regulariser implementations in this repository.
Class
Define the base interface for regulariser operators. |
- class hyri.regulariser.regulariser.Regulariser(rank_num_ch: int = 1, rank_ch_start: int = 0, device: device = device(type='cpu'), dtype: dtype = torch.float32)#
Bases:
ABCDefine the base interface for regulariser operators.
Subclasses implement
__call__()to apply a regularisation step andupdate()to refresh internal state between optimisation iterations.- _device#
Device used for operator state and outputs.
- Type:
- _dtype#
Tensor dtype used by the operator.
- Type:
Initialise shared regulariser state.
- 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 for regulariser state and outputs. Default: torch.device(“cpu”).
dtype (torch.dtype, optional) – Tensor dtype used by the regulariser. Default: torch.float.
Note
When torch.distributed is initialised, this constructor caches rank metadata and chooses a point-to-point communication device based on the active backend.
- abstract __call__(x: Tensor) Any#
Apply the regulariser to an input tensor.
- Parameters:
x (torch.Tensor) – Input tensor in image domain.
- Returns:
Regularised output produced by a concrete implementation.
- Return type:
Any
- abstract update(*args, **kwargs) Any#
Update internal regulariser state.
- Parameters:
*args (Any) – Positional arguments required by the subclass.
**kwargs (Any) – Keyword arguments required by the subclass.
- Returns:
Optional update artefacts returned by the subclass.
- Return type:
Any
- get_device() device#
Return the regulariser execution device.
- Returns:
Device used for internal state and outputs.
- Return type: