mxnet.npx.batch_flatten

batch_flatten(data=None, out=None, name=None, **kwargs)

Flattens the input array into a 2-D array by collapsing the higher dimensions. .. note:: Flatten is deprecated. Use flatten instead. For an input array with shape (d1, d2, ..., dk), flatten operation reshapes the input array into an output array of shape (d1, d2*...*dk). Note that the behavior of this function is different from numpy.ndarray.flatten, which behaves similar to mxnet.ndarray.reshape((-1,)). Example:

x = [[
    [1,2,3],
    [4,5,6],
    [7,8,9]
],
[    [1,2,3],
    [4,5,6],
    [7,8,9]
]],
flatten(x) = [[ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.],
   [ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.]]

Defined in /work/mxnet/src/operator/tensor/matrix_op.cc:L278

Parameters
  • data (ndarray) – Input array.

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

Returns

out – The output of this function.

Return type

ndarray or list of ndarrays