spyrit.core.meas.DynamicLinear.vectorize

DynamicLinear.vectorize(input: tensor) tensor

Flatten the measured dimensions.

The tensor is flattened at the indicated self.meas_dims dimensions. The flattened dimensions are then collapsed into one, which is the last dimension of the output tensor.

Input:

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

Output:

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

See also:

For the opposite operation use unvectorize().

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, 5, 7, 12)
>>> print(meas_op.vectorize(x).shape)
torch.Size([3, 7, 60])