Table Of Contents
Table Of Contents


mxnet.ndarray.stack(*data, **kwargs)

Join a sequence of arrays along a new axis.

The axis parameter specifies the index of the new axis in the dimensions of the result. For example, if axis=0 it will be the first dimension and if axis=-1 it will be the last dimension.


x = [1, 2]
y = [3, 4]

stack(x, y) = [[1, 2],
               [3, 4]]
stack(x, y, axis=1) = [[1, 3],
                       [2, 4]]
  • data (NDArray[]) – List of arrays to stack

  • axis (int, optional, default='0') – The axis in the result array along which the input arrays are stacked.

  • out (NDArray, optional) – The output NDArray to hold the result.


out – The output of this function.

Return type

NDArray or list of NDArrays