spyrit.core.noise.PoissonApproxGauss.forward
- PoissonApproxGauss.forward(z: tensor) tensor[source]
Corrupt measurement by Gaussian approximation of Poisson noise
\[y \sim \alpha z + \sqrt{\alpha z} \cdot \mathcal{N}(0, 1) \quad \text{with }z\ge 0\]- Args:
z(torch.tensor): Measurements \(z\) with arbitrary shape.- Returns:
torch.tensor: Noisy measurement \(y\) with the same shape asz.- Raises:
RuntimeError: If there are negative values in the input tensor.
- Example:
Two different noisy measurement vectors
>>> import spyrit.core.noise as sn >>> import torch >>> noise = sn.PoissonApproxGauss(100) >>> z = torch.empty(10, 4).uniform_(0, 1) >>> y = noise(z) >>> print(y.shape) torch.Size([10, 4]) >>> print(f"Noiseless measurements in ({torch.min(z):.2f} , {torch.max(z):.2f})") Noiseless measurements in (...) >>> print(f"Noisy measurements in ({torch.min(y):.2f} , {torch.max(y):.2f})") Noisy measurements in (...)
>>> y = noise(z) >>> print(f"Noisy measurements in ({torch.min(y):.2f} , {torch.max(y):.2f})") Noisy measurements in (...)