mxnet.np.full

full(shape, fill_value, dtype=None, order='C', device=None, out=None)

Return a new array of given shape and type, filled with fill_value.

Parameters
  • shape (int or sequence of ints) – Shape of the new array, e.g., (2, 3) or 2.

  • fill_value (scalar or ndarray) – Fill value.

  • dtype (data-type, optional) – If dtype is None, the output array data type must be inferred from fill_value. If it’s an int, the output array dtype must be the default integer dtype; If it’s a float, then the output array dtype must be the default floating-point data type; If it’s a bool then the output array must have boolean dtype. Default: None.

  • order ({'C'}, optional) – Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory. Currently only supports C order.

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

  • out (ndarray or None, optional) – A location into which the result is stored. If provided, it must have the same shape and dtype as input ndarray. If not provided or None, a freshly-allocated array is returned.

Returns

  • out (ndarray) – Array of fill_value with the given shape, dtype, and order. If fill_value is an ndarray, out will have the same device as fill_value regardless of the provided device.

  • .. note:: – This function differs from the original numpy.full in the following way(s):

    • Has an additional device argument to specify the device

    • Has an additional out argument

    • Currently does not support order selection

See also

empty()

Return a new uninitialized array.

ones()

Return a new array setting values to one.

zeros()

Return a new array setting values to zero.

Examples

>>> np.full((2, 2), 10)
array([[10., 10.],
       [10., 10.]])
>>> np.full((2, 2), 2, dtype=np.int32, device=mx.cpu(0))
array([[2, 2],
       [2, 2]], dtype=int32)