spyrit.core.meas.Linear.unvectorize

Linear.unvectorize(input: tensor) tensor[source]

Unflatten the measured dimensions.

This method first expands the last dimension into the measurement shape (self.meas_shape), and then moves the expanded dimensions to their original positions as defined by self.meas_dims.

Input:

input (torch.tensor): A tensor of shape (*, self.N) where * denotes any batch size.

Output:

torch.tensor: A tensor whose dimensions given by self.meas_dims have shape self.meas_shape.

See also:

For the opposite operation use vectorize().

Example:
>>> import spyrit.core.meas as meas
>>> matrix = torch.randn(10, 60)
>>> meas_op = meas.Linear(matrix, meas_shape=(12, 5), meas_dims=(-1,-3))
>>> x = torch.randn(3, 7, 60)
>>> print(meas_op.unvectorize(x).shape)
torch.Size([3, 5, 7, 12])