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 intox.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 ofsizesmust equalinput.shape[dim].
- Return type:
Array| saiunit.Quantity- Returns:
A tensor with the same data as
input, but withdimsplit 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))