spyrit.core.meas.FreeformLinearSplit.forward

FreeformLinearSplit.forward(x: tensor) tensor[source]

Simulate measurements.

The mask is first applied to the input tensor, then the input tensor is multiplied by the measurement patterns.

Note

This method does not include the noise model.

Args:

x (torch.tensor): A tensor where the dimensions indexed by self.meas_dims match the measurement shape self.meas_shape.

Returns:

torch.tensor: A tensor of shape (*, self.M) where * denotes all the dimensions of the input tensor not included in self.meas_dims.

Example: Select one every second point on the diagonal of a batch of images
>>> from spyrit.core.meas import FreeformLinearSplit
>>> import torch
>>> images = torch.rand(17, 3, 40, 40)
>>> mask = torch.tensor([[i, i] for i in range(0,40,2)]).T
>>> H = torch.randn(13, 20)
>>> meas_op = FreeformLinearSplit(H, meas_shape=(40,40), index_mask=mask)
>>> x_masked = meas_op(images)
>>> print(x_masked.shape)
torch.Size([17, 3, 26])