numpy.zeros_like
2017-06-03 09:41
387 查看
numpy.zeros_like
numpy.zeros_like(a,dtype=None,order='K', subok=True)[source]
Return an array of zeros with the same shape and type as a given array.
Parameters: | a : array_like The shape and data-type of a define these same attributes ofthe returned array. dtype : data-type, optional Overrides the data type of the result. New in version 1.6.0. order : {‘C’, ‘F’, ‘A’, or ‘K’}, optional Overrides the memory layout of the result. ‘C’ means C-order,‘F’ means F-order, ‘A’ means ‘F’ ifa is Fortran contiguous,‘C’ otherwise. ‘K’ means match the layout ofa as closelyas possible. New in version 1.6.0. subok : bool, optional. If True, then the newly created array will use the sub-classtype of ‘a’, otherwise it will be a base-class array. Defaultsto True. |
---|---|
Returns: | out : ndarray Array of zeros with the same shape and type as a. |
ones_likeReturn an array of ones with shape and type of input.empty_likeReturn an empty array with shape and type of input.zerosReturn a new array setting values to zero.onesReturn a new array setting values to one.emptyReturn a new uninitialized array.
Example
c45d
s
>>>
>>> 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]])
>>>
>>> y = np.arange(3, dtype=np.float) >>> y array([ 0., 1., 2.]) >>> np.zeros_like(y) array([ 0., 0., 0.])
相关文章推荐
- numpy.zeros_like 使用法
- numpy.zeros 使用方法 python学习笔记1
- NumPy(1)简介,基础属性,数组创建(ones,zeros,empty,arange,linespace)
- numpy.zeros()
- numpy.zeros(shape, dtype=float, order='C')
- python中numpy.zeros(np.zeros)的使用方法
- Numpy.Zeros等
- numpy.ones_like(a, dtype=None, order='K', subok=True)返回和原矩阵一样形状的1矩阵
- numpy中的zeros(),ones()函数
- python: numpy -- zeros,ones,eyes函数
- Python的numpy模块之zeros()
- numpy.zeros
- Python的numpy模块之zeros()
- python:numpy-zeros(),ones(),eyes()
- numpy.zeros((5,))中(5,)的含义 顺便复习Python中tuple的用法
- numpy.random.choice和zeros的用法
- python: numpy -- zeros,ones,eyes函数
- NumPy v1.13 - numpy.zeros
- numpy.zeros(np.zeros)使用方法--python学习笔记31
- python zeros()使用(from numpy import *)