stack

dragon.stack(
  inputs,
  axis=0,
  **kwargs
)[source]

Stack the inputs along the given axis.

All the dimensions of inputs should be same:

x1 = dragon.ones(shape=(2, 3))
x2 = dragon.zeros(shape=(2, 4))
y = dragon.stack([x1, x1])  # Ok
z = dragon.stack([x1, x2])  # Wrong

axis can be negative:

x = dragon.constant([[1, 2], [3, 4]])
y = dragon.stack([x, x], axis=1)
z = dragon.stack([x, x], axis=-1)  # Equivalent
Parameters:
  • inputs (Sequence[dragon.Tensor]) – The input tensors.
  • axis (int, optional, default=0) – The axis to stack.
Returns:

dragon.Tensor – The output tensor.