spyrit.core.meas.Linear

class spyrit.core.meas.Linear(H: tensor, meas_shape: int | Size | Iterable[int] = None, meas_dims: int | Size | Iterable[int] = None, *, noise_model: Module = Identity(), dtype: dtype = torch.float32, device: device = device(type='cpu'))[source]

Bases: Module

Simulates linear 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.

Important

The vector \(x \in \mathbb{R}^N\) represents a multi-dimensional array (e.g, an image \(X \in \mathbb{R}^{N_1 \times N_2}\) with \(N = N_1 \times N_2\)).

Args:

H (torch.tensor): measurement matrix (linear operator) with shape \((M, N)\). Only real values are supported.

meas_shape (tuple, optional): Shape of the underliying multi-dimensional array \(X\). Must be a tuple of integers \((N_1, ... ,N_k)\) such that \(\prod_k N_k = N\). If not, an error is raised. Defaults to None.

meas_dims (tuple, optional): Dimensions of \(X\) the acquisition matrix applies to. Must be a tuple with the same length as meas_shape. If not, an error is raised. Defaults to the last dimensions of the multi-dimensional array \(X\) (e.g., (-2,-1) when len(meas_shape)).

noise_model (see spyrit.core.noise): Noise model \(\mathcal{N}\). Defaults to = torch.nn.Identity.

Attributes:

H (torch.tensor): (Learnable) measurement matrix of shape \((M, N)\) initialized as \(H\).

meas_shape (tuple): Shape of the underliying multi-dimensional array \(X\).

meas_dims (tuple): Dimensions the acquisition matrix applies to.

meas_ndim (int): Number of dimensions the acquisition matrix applies to. This is len(meas_dims)

noise_model (see spyrit.core.noise): Noise model \(\mathcal{N}\).

M (int): Number of measurements \(M\).

Example: (to be updated!)

Example 1:

>>> H = torch.rand([400, 1600])
>>> meas_op = Linear(H)
>>> print(meas_op)
Linear(
  (noise_model): Identity()
)

Methods

adjoint(m[, unvectorize])

Apply adjoint of matrix H.

forward(x)

Simulate noisy measurements

measure(x)

Simulate noiseless measurements

unvectorize(input)

Unflatten the measured dimensions.

vectorize(input)

Flatten the measured dimensions.