mrpro.utils.unsqueeze_tensors_at

mrpro.utils.unsqueeze_tensors_at(*x, dim: int, ndim: int | None = None) tuple[Tensor, ...][source]

Unsqueeze tensors at a specific dimension to the same number of dimensions.

Example

  • Tensors with shapes (1,2,3) and (1,3) and dim=-2 results in tensors with shape (1,2,3) and (1,1,3), as the maximum number of input dimensions is 3.

  • Tensors with shapes (1,2,3) and (1,3) and dim=1 and ndim=4 results in tensors with shape (1,1,2,3) and (1,1,1,3).

Parameters:
  • x – tensors to unsqueeze

  • dim (int) – dimension to unsqueeze

  • ndim (int | None, default: None) – number of dimensions to unsqueeze to. If None, unsqueeze to the maximum number of dimensions of the input tensors.

Returns:

unsqueezed tensors (views) with the same number of dimensions