mxnet.np.zeros_like

zeros_like(a, dtype=None, order='C', device=None, out=None)

Return an array of zeros with the same shape and type as a given array.

Parameters
  • a (ndarray) – The shape and data-type of a define these same attributes of the returned array.

  • dtype (data-type, optional) – Overrides the data type of the result. Temporarily do not support boolean type.

  • 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 – Array of zeros with the same shape and type as a.

Return type

ndarray

See also

empty_like()

Return an empty array with shape and type of input.

ones_like()

Return an array of ones with shape and type of input.

zeros_like()

Return an array of zeros with shape and type of input.

full()

Return a new array of given shape filled with value.

Examples

>>> x = np.arange(6)
>>> x = x.reshape((2, 3))
>>> x
array([[0., 1., 2.],
       [3., 4., 5.]])
>>> np.zeros_like(x)
array([[0., 0., 0.],
       [0., 0., 0.]])
>>> np.zeros_like(x, int)
array([[0, 0, 0],
       [0, 0, 0]], dtype=int64)
>>> y = np.arange(3, dtype=float)
>>> y
array([0., 1., 2.], dtype=float64)
>>> np.zeros_like(y)
array([0., 0., 0.], dtype=float64)