python 的 python中numpy.zeros(np.zeros)的使用方法

翻译:

用法:zeros(shape, dtype=float, order='C')

返回:返回来一个给定形状和类型的用0填充的数组;

参数:shape:形状

dtype:数据类型,可选参数,默认numpy.float64

dtype类型:

t ,位域,如t4代表4位

b,布尔值,true or false

i,整数,如i8(64位)

u,无符号整数,u8(64位)

f,浮点数,f8(64位)

c,浮点负数,

o,对象,

s,a,字符串,s24

u,unicode,u24

order:可选参数,c代表与c语言类似,行优先;F代表列优先

例子:

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', '

########################################################

zeros(shape, dtype=float, order='C')

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', '

Type: builtin_function_or_method

以上这篇python中numpy.zeros(np.zeros)的使用方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

python中zeros用法_python中numpy.zeros(np.zeros)的使用方法相关推荐

  1. python中zeros用法_Python中的numpy.zeros()用法

    numpy.zeros()函数是最重要的函数之一, 广泛用于机器学习程序中.此函数用于生成包含零的数组. numpy.zeros()函数提供给定形状和类型的新数组, 并用零填充. 句法 numpy.z ...

  2. python isnumeric函数用法_Python中isnumeric()方法的使用简介

    Python中isnumeric()方法的使用简介 更新时间:2015年05月19日 09:35:06 投稿:goldensun 这篇文章主要介绍了Python中isnumeric()方法的使用,is ...

  3. python的继承用法_python中继承有什么用法?python继承的用法详解

    本篇文章给大家带来的内容是关于python中继承有什么用法?python继承的用法详解,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 面向对象三大特征 1.封装:根据职责将属性和方法 ...

  4. python if函数用法_python中if条件中的Contains()函数“in”

    我对contains()in的功能做了一些研究,特别是与eq()==进行了比较,发现它可以完成许多任务.我设法回答了其中许多问题(见下文). 除了下面的用法之外,in还有其他有用的用法吗,例如对象?在 ...

  5. python中sorted用法_Python中sorted()方法的用法

    1.先说一下iterable,中文意思是迭代器. Python的帮助文档中对iterable的解释是:iteralbe指的是能够一次返回它的一个成员的对象.iterable主要包括3类: 第一类是所有 ...

  6. python中rjust用法_python中rjust的用法

    英文对话是要加引号的,而且是双引号和单引号的使用方法与中文一样的用法,接下来小编在这里给大家带来,我们一起来看看吧!引号分单引号(singlequotationmarks)和双引号(doublequo ...

  7. python isalpha函数用法_python中string模块各属性以及函数的用法

    任何语言都离不开字符,那就会涉及对字符的操作,尤其是脚本语言更是频繁,不管是生产环境还是面试考验都要面对字符串的操作. python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求 ...

  8. python or的用法_python中and和or的用法

    原博文 2013-01-19 13:40 − From <dive into python> python 中的and从左到右计算表达式,若所有值均为真,则返回最后一个值,若存在假,返回第 ...

  9. python的继承用法_Python 中的继承之Super用法

    以下Copy自官方文档说明,可点击查看官网源文 翻译内容属于德德自译,有不当之处请指正,勿喷... 翻译括弧中是德德自己理解,通过代码验证的,勿喷... super(type[, object-or- ...

最新文章

  1. mybatis学习笔记二(接口注解)
  2. 《陶哲轩实分析》引理17.2.4证明_导数的唯一性
  3. 4-3:TCP协议之UDP协议
  4. 非阻塞式JavaScript脚本介绍
  5. pandas dataframe使用query进行多个条件快速筛选
  6. pytorch torch.empty
  7. 谁说男生不能美美哒?2020中国男士美妆市场洞察报告.pdf(附下载链接)
  8. python没有pygame_教程丨python 做一个简单的MP3
  9. 关于 u-nas 报警声音
  10. 分销商城系统模块_分销商城系统模块需求分析_OctShop
  11. 学嵌入式职业发展方向有哪些?
  12. KEIL识别不出野火STM32仿真器问题解决
  13. Erlang中的fun函数使用详解
  14. Pythom爬虫之图虫小姐姐图片的爬取:
  15. Windows使用dos窗口打开应用
  16. java转换大小写快捷键_Java 大小写最快转换方式实例代码
  17. 区块链三加一:币圈,你最需要知道的八大问题!
  18. 这年头,能坐上火箭的东西不多啊!Java版本号算一个!
  19. 你相信命运吗?还有命运规划局?
  20. MQTT搭建(Windows和Linux)版

热门文章

  1. ORB_SLAM2配置安装及测试
  2. C#中HttpWebRequest的用法详解
  3. 中国智能马桶市场投资前景分析及供需格局研究预测报告
  4. C语言编程题:选民投票
  5. 【实习小tip】elementUI表格数值加减和实时计算、导出数据并解决手机号科学计数法格式问题、git clone报错:OpenSSL SSL_connect: SSL_ERROR_SYSCALL
  6. 荣耀笔记本开机显示 grub 界面
  7. java构造方法命名_Java命名规范
  8. 小米答题题库_@小伙伴们 快来答题领木耳、香菇等土特产了,转发集赞还有新年礼包...
  9. 北京科技大学计算机复试难度,北京科技大学考研难度怎么样
  10. Three——三、动画执行、画布大小、渲染帧率和相机适配体验