numpy.zeros
-
Return a new array of given shape and type, filled with zeros
-
例:
-
1,np.zeros((3, 5), dtype=np.uint8)
输出:[[0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0]]
-
2,np.zeros(2, dtype=np.uint8) 输出:
[0 0]
-
类似的还有
-
numpy.ones
-
Return a new array of given shape and type, filled with ones.
Parameters: shape : int or sequence of ints
Shape of the new array, e.g.,
(2, 3)
or2
.dtype : data-type, optional
The desired data-type for the array, e.g.,
numpy.int8
. Default isnumpy.float64
.order : {‘C’, ‘F’}, optional
Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory.
Returns: out : ndarray
Array of ones with the given shape, dtype, and order.
numpy.
ones
( shape, dtype=None, order='C' ) [source] -
numpy.
zeros
(
shape,
dtype=float,
order='C'
)
Parameters: | shape : int or sequence of ints
dtype : data-type, optional
order : {‘C’, ‘F’}, optional
|
---|---|
Returns: | out : ndarray
|