full

full(shape, fill_value, dtype=None, order='C', ctx=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

Fill value.

dtype : data-type, optional

The desired data-type for the array. The default, None, means np.array(fill_value).dtype.

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.

ctx: to specify the device, e.g. the i-th GPU.
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.

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.

Notes

This function differs from the original `numpy.full https://docs.scipy.org/doc/numpy/reference/generated/numpy.full.html`_ in the following way(s):

  • Has an additional ctx argument to specify the device
  • Has an additional out argument
  • Currently does not support order selection

Examples

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