spyrit.core.meas.Linear.forward

Linear.forward(x: tensor)[source]

Simulate noisy measurements

\[m =\mathcal{N}\left(Hx\right),\]

where \(\mathcal{N} \colon\, \mathbb{R}^M \to \mathbb{R}^M\) represents a noise operator (e.g., Gaussian), \(H\in\mathbb{R}^{M\times N}\) is the acquisition matrix, \(x \in \mathbb{R}^N\) is the signal of interest, \(M\) is the number of measurements, and \(N\) is the dimension of the signal.

Note

This method degrades measurements with noise. To compute \(Hx\) only, see measure().

Args:

x (torch.tensor): A batch of signals \(x\). The dimensions indexed by self.meas_dims must match the measurement shape self.meas_shape.

Returns:

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

Example:

Example 1: (3, 4) signals of length 15 are measured with an acquisition matrix of shape (10, 15). This produces (3, 4) measurements of length 10.

>>> H = torch.randn(10, 15)
>>> meas_op = Linear(H)
>>> x = torch.randn(3, 4, 15)
>>> y = meas_op(x)
>>> print(y.shape)
torch.Size([3, 4, 10])

Example 2: 3 signals of length (15, 4) are measured with an acquisition matrix of shape (10, 60). This produces 3 measurements of length 10. The acquisition matrix applies to both dimensions -2 and -1.

>>> H = torch.randn(10, 60)
>>> meas_op = Linear(H, meas_shape=(15, 4))
>>> x = torch.randn(3, 15, 4)
>>> y = meas_op(x)
>>> print(y.shape)
torch.Size([3, 10])
>>> print(meas_op.meas_dims)
torch.Size([-2, -1])