numpy.zeros

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

Parameters:

shape : int or sequence of ints

Shape of the new array, e.g., (2, 3) or 2.

dtype : data-type, optional

The desired data-type for the array, e.g., numpy.int8. Default is numpy.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 zeros with the given shape, dtype, and order.

See also

zeros_like
Return an array of zeros with shape and type of input.
ones_like
Return an array of ones with shape and type of input.
empty_like
Return an empty array with shape and type of input.
ones
Return a new array setting values to one.
empty
Return a new uninitialized array.

Examples

>>>

>>> np.zeros(5)
array([ 0., 0., 0., 0., 0.])
>>>

>>> np.zeros((5,), dtype=np.int)
array([0, 0, 0, 0, 0])
>>>

>>> np.zeros((2, 1))
array([[ 0.],
[ 0.]])
>>>

>>> s = (2,2)
>>> np.zeros(s)
array([[ 0., 0.],
[ 0., 0.]])
>>>

>>> np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
array([(0, 0), (0, 0)],
dtype=[('x', '<i4'), ('y', '<i4')])

最新文章

  1. ASP.NET MVC之如何看待内置配置来提高性能优化(四)
  2. 列间距column-gap
  3. .htaccess根据IP地址限制访问
  4. CentOS的安装与克隆
  5. Unity-Animator深入系列---控制IK
  6. Duilib中系统消息在自己窗口类的使用
  7. tomcat 多开设置 需要需改的3个端口
  8. 知问前端——概述及jQuery UI
  9. ios7高级
  10. win7下go web之revel
  11. thinking in java 随笔
  12. Spring(二):Spring框架&amp;Hello Spring
  13. 四、Tensorflow的分布式训练
  14. audio元素和video元素在ios和andriod中无法自动播放
  15. 9. Web browser-related (网页浏览器相关 4个)
  16. java PDF添加图层,支持多页图层添加
  17. 浅谈MemCahe
  18. web前端学习路线(含20个真实web开发项目集合)
  19. Angularjs集成第三方js插件之Uploadify
  20. POJ 1946 Cow Cycling(抽象背包, 多阶段DP)

热门文章

  1. Linux基础系列:常用命令(6)_nfs服务与nginx服务
  2. AbstractQueuedSynchronizer(一)
  3. Unity Json解析IPA
  4. POJ 之2386 Lake Counting
  5. Spark- SparkStreaming可更新状态的实例
  6. 深度学习—BN的理解(二)
  7. C++(四)— 字符串、数字翻转3种方法
  8. Mybatis_学习_00_资源帖
  9. Eclipse_常用技巧_03_字母大小写转换快捷键
  10. alt+shift+j 自动添加类的文档注释 Myeclipse