mxnet.np.empty

empty(shape, dtype=None, order='C', device=None)

Return a new array of given shape and type, without initializing entries.

Parameters
  • shape (int or tuple of int Shape of the empty array, e.g., (2, 3) or 2.) –

  • dtype (data-type, optional) – Desired output data-type for the array, e.g, numpy.int8. Note that this behavior is different from NumPy’s empty function where float64 is the default value, here you can set your default dtype as ‘float32’ or ‘float64’ because float32 is considered as the default data type in deep learning. When npx.is_np_default_dtype() returns False, default dtype is float32; When npx.is_np_default_dtype() returns True, default dtype is float64.

  • order ({'C'}, optional, default: 'C') – How to store multi-dimensional data in memory, currently only row-major (C-style) is supported.

  • device (Device, optional) – Device context on which the memory is allocated. Default is mxnet.device.current_device().

Returns

out – Array of uninitialized (arbitrary) data of the given shape, dtype, and order.

Return type

ndarray

Examples

>>> np.empty([2, 2])
array([[ 0.000000e+00, -2.524355e-29],
       [          nan, -8.592023e+09]])  # uninitialized
>>> np.empty([2, 2], dtype=int)
array([[8751743591039004782, 3196766424264760104],
       [7583328881310196768,     562950123910254]], dtype=int64)  # uninitialized