unflatten

Contents

unflatten#

class saiunit.math.unflatten(x, axis, sizes, **kwargs)#

Expands a dimension of the input tensor over multiple dimensions.

Parameters:
  • x (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – input tensor.

  • axis (int) – Dimension to be unflattened, specified as an index into x.shape.

  • sizes (Sequence[int]) – New shape of the unflattened dimension. One of its elements can be -1 in which case the corresponding output dimension is inferred. Otherwise, the product of sizes must equal input.shape[dim].

Return type:

Array | saiunit.Quantity

Returns:

A tensor with the same data as input, but with dim split into multiple dimensions. The returned tensor has one more dimension than the input tensor. The returned tensor shares the same underlying data with this tensor.

Examples

>>> import saiunit as u
>>> a = [1, 2, 3, 4, 5, 6] * u.meter
>>> u.math.unflatten(a, 0, (2, 3))