spyrit.core.recon.PositiveParameters
- class spyrit.core.recon.PositiveParameters(params, requires_grad=True)[source]
Bases:
ModuleModule that stores a signed tensor and returns its absolute value.
This module is used to store the step size of the LearnedPGD network. The step size must be positive, so it is stored as a signed tensor and its absolute value is returned when the module is called.
- Args:
params (array_like): Signed array-like object. It is used to construct a new tensor.
requires_grad (bool): If True, the tensor requires gradient. Default is True.
- Attributes:
params(torch.tensor): Signed tensor.- Methods:
forward(): Returns the absolute value of the signed tensor.- Example:
>>> values = [-1., 2., -3., 4.] >>> pos_params = PositiveParameters(values) >>> print(pos_params.params) tensor([-1., 2., -3., 4.], requires_grad=True) >>> print(pos_params()) tensor([1., 2., 3., 4.], grad_fn=<AbsBackward0>)
Methods
forward()Returns the absolute value of the stored signed tensor.