spyrit.core.meas.DynamicLinear.forward
- DynamicLinear.forward(x: tensor) tensor[source]
Simulates noisy dynamic measurements.
\[m = \mathcal{N}\left(\text{diag}(H x_{t=1, ..., M})\right),\]where \(H \in \mathbb{R}^{M \times N}\) is the acquisition matrix, \(x_{t=1, ..., M} \in \mathbb{R}^{N \times M}\) is the temporal signal of interest, \(M\) is both the number of measurements and frames, \(N\) is the dimension of the signal in the field of view, and \(\text{diag}\colon\, \mathbb{R}^{M \times M} \to \mathbb{R}^M\) extracts the diagonal of its input.
Note
This method degrades measurements with noise. To compute \(Hx_{t=1, ..., M}\) only, see
measure().- Args:
x(torch.tensor): A batch of temporal signals whose time dimension matchesself.time_dim, and measured dimensions matchesself.meas_dims.- Returns:
torch.tensor: A batch of measurement of shape \((*, M)\) where * denotes all the dimensions of the input tensor that are not included inself.meas_dims.- Example:
>>> import torch >>> from spyrit.core.meas import DynamicLinear >>> from spyrit.core.noise import Poisson >>> >>> x = torch.rand([1, 400, 3, 50, 50]) # dummy RGB video with 400 frames of size 50x50 >>> H = torch.rand([400, 40*40]) # dummy static measurement matrix >>> alpha = 5 # noise level >>> noise_op = Poisson(alpha=alpha, g=1/alpha) >>> meas_op = DynamicLinear(H, time_dim=1, meas_shape=(40, 40), img_shape=(50, 50), noise_model=noise_op) >>> print(meas_op) DynamicLinear( (noise_model): Poisson() ) >>> >>> m = meas_op(x) # simulate noisy dynamic measurements >>> print(m.shape) torch.Size([1, 3, 400])