type:python内置函数,用来获取变量的数据结构类型

>> print(type(x_train))
<class 'numpy.ndarray'>
>> a=[1,2,3,4]
>> print(type(a))
<class 'list'>

dtype:获取变量的数据类型
注: list、dict 等可以包含不同的数据类型,因此没有dtype属性。

>> print(x_train.dtype)
uint8
a=[1,2,'s',200.2]
print(a.dtype)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-2377a652fbf4> in <module>1 a=[1,2,'s',200.2]
----> 2 print(a.dtype)AttributeError: 'list' object has no attribute 'dtype'

astype:对数据类型进行转换

>>x_train = x_train.reshape(-1, 28, 28, 1)
>>print(x_train.dtype)
uint8>>x_train = x_train.astype('float32')
>>print(x_train.dtype)
float32

type、dtype和astype相关推荐

  1. python中dtype什么意思_浅谈python 中的 type(), dtype(), astype()的区别

    如下所示: 函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list. ...

  2. python 中的 type(), dtype(), astype()的区别

    函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list.dict 等 ...

  3. 浅谈Python中的type()、dtype()、astype()的区别

    函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等)备注:1.由于 list.dict 等可 ...

  4. python中type(),dtype(),astype()的区别

    python中type(),dtype(),astype()的区别 type(): 返回的是数据结构的类型(list, dict,numpy.ndarry) >>> k = [1, ...

  5. Python中辨析type/dtype/astype用法

    Python中与数据类型相关函数及属性有如下三个:type/dtype/astype. 名称    描述 type()    返回参数的数据类型 dtype    返回数组中元素的数据类型 astyp ...

  6. Python中type/dtype/astype用法

    Python中与数据类型相关函数及属性有如下三个:type/dtype/astype. 名称 描述 type() 返回参数的数据类型 dtype 返回数组中元素的数据类型 astype() 对数据类型 ...

  7. python dtype什么意思_浅谈python 中的 type(), dtype(), astype()的区别

    如下所示: 函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list. ...

  8. python中astype用法_浅谈python 中的 type(), dtype(), astype()的区别

    如下所示: 函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list. ...

  9. Python-辨析type/dtype/astype用法

    Python中与数据类型相关函数及属性有如下三个:type/dtype/astype. 名称 描述 type() 返回参数的数据类型 dtype 返回数组中元素的数据类型 astype() 对数据类型 ...

  10. type/dtype/astype的作用

    1.type():可以接受任何数据结构,并返回数据结构的类型,例:list,dict,set,numpy.ndarray 2.dtype:调用有限制,数据结构类型内必须只包含一种数据类型,list,d ...

最新文章

  1. 源文件封装为IP的步骤
  2. github javaguide_GitHub上收获Star数排名前10的Java项目
  3. VLAN+DHCP(1)(附抓包)
  4. 如何解决SSL/TLS握手过程中失败的错误?
  5. 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
  6. MyBatis-Plus 快速开始及详测 SpringBoot 集成Mybatis-Plus
  7. plupload+artdialog实现多平台文件上传
  8. 如何在使用Retry之后,Jenkins能够准确发送邮件的脚本
  9. java递归统计一个文件夹含子文件夹里文件不同后缀的出现次数
  10. Jenkins 2.322 安装 自定义插件
  11. Android测量图像中物体大小,android – 加载图像后测量ImageView
  12. pic单片机 c语言开发环境,《PIC单片机开发环境入门》.pdf
  13. 定位弹窗软件----找到真凶并做后续防御
  14. 行测-判断推理-图形推理-样式规律-黑白运算
  15. Tensorflow图像处理相关操作
  16. java基于ssm+mysql学生课程表现作业评价系统
  17. 为什么微信连接不上服务器失败怎么回事啊,微信为什么一直提示连接失败请检查网络设置...
  18. PostgreSQL 14 pageinspect新增gist索引支持
  19. The error may exist in bshr/mapper/PfmMapper.xml ### The error may involve defaultParameterMap
  20. 学习率设置的学问(如何设置学习率)

热门文章

  1. Apollo学习(一)Apollo初学入门
  2. 储罐液位计算机控制系统,罐区管理系统
  3. 查看python openCV的版本号
  4. Python搭建开发环境
  5. 对抗训练-smart 论文阅读笔记
  6. 如何用Photoshop来磨皮人脸图
  7. 2020-04-12
  8. [编译原理学习笔记2-2] 程序语言的语法描述
  9. c语言学生成绩设计思路,C语言学生成绩管理系统设计.docx
  10. 8通道CAN FD,更强大的数据记录仪GL3400