spyrit.core.meas.HadamSplit2d.fast_pinvļ
- HadamSplit2d.fast_pinv(m: tensor, vectorize=False) tensor[source]ļ
Apply the pseudo inverse of H.
- Args:
m(torch.tensor): Measurement \(m\) of lengthself.M.vectorize(bool): Whether to apply thevectorize()method after computation of the pseudo inverse.- Returns:
torch.tensor: Vectorized image \(x\) of lengthself.N.
Note
We use the separability of the 2D Hadamard transform. Only multiplications with the ā1Dā Hadamard matrix (i.e.,
self.H1d) are required. If the number of measurements is smaller than the number of pixels, the measurement vector is zero-padded.- Examples:
Example 1: No subsampling
>>> import torch >>> import spyrit.core.meas as meas >>> h = 32 >>> meas_op = meas.HadamSplit2d(h) >>> m = torch.empty(10, h*h).uniform_(0, 1) >>> x = meas_op.fast_pinv(m) >>> print(x.shape) torch.Size([10, 32, 32])
Example 2: With subsampling
>>> import torch >>> import spyrit.core.meas as meas >>> h, M = 32, 49 >>> meas_op = meas.HadamSplit2d(h, M) >>> m = torch.empty(8, 2, M).uniform_(0, 1) >>> x = meas_op.fast_pinv(m) >>> print(x.shape) torch.Size([8, 2, 32, 32])
Example 3: Output are vectors, not images
>>> import torch >>> import spyrit.core.meas as meas >>> h, M = 32, 49 >>> meas_op = meas.HadamSplit2d(h, M) >>> m = torch.empty(8, 2, M).uniform_(0, 1) >>> x = meas_op.fast_pinv(m, vectorize=True) >>> print(x.shape) torch.Size([8, 2, 1024])