mrpro.utils.unsqueeze_at

mrpro.utils.unsqueeze_at(x: Tensor, dim: int, n: int) Tensor[source]

Unsqueeze multiple times at a specific dimension.

Example

Tensor with shape (1,2,3) and dim=2 and n=2 would result in tensor with shape (1,2,1,1,3).

Parameters:
  • x (Tensor) – tensor to unsqueeze

  • dim (int) – dimension to unsqueeze. Negative values are allowed.

  • n (int) – number of times to unsqueeze