type、dtype和astype
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相关推荐
- python中dtype什么意思_浅谈python 中的 type(), dtype(), astype()的区别
如下所示: 函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list. ...
- python 中的 type(), dtype(), astype()的区别
函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list.dict 等 ...
- 浅谈Python中的type()、dtype()、astype()的区别
函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等)备注:1.由于 list.dict 等可 ...
- python中type(),dtype(),astype()的区别
python中type(),dtype(),astype()的区别 type(): 返回的是数据结构的类型(list, dict,numpy.ndarry) >>> k = [1, ...
- Python中辨析type/dtype/astype用法
Python中与数据类型相关函数及属性有如下三个:type/dtype/astype. 名称 描述 type() 返回参数的数据类型 dtype 返回数组中元素的数据类型 astyp ...
- Python中type/dtype/astype用法
Python中与数据类型相关函数及属性有如下三个:type/dtype/astype. 名称 描述 type() 返回参数的数据类型 dtype 返回数组中元素的数据类型 astype() 对数据类型 ...
- python dtype什么意思_浅谈python 中的 type(), dtype(), astype()的区别
如下所示: 函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list. ...
- python中astype用法_浅谈python 中的 type(), dtype(), astype()的区别
如下所示: 函数 说明 type() 返回数据结构类型(list.dict.numpy.ndarray 等) dtype() 返回数据元素的数据类型(int.float等) 备注:1)由于 list. ...
- Python-辨析type/dtype/astype用法
Python中与数据类型相关函数及属性有如下三个:type/dtype/astype. 名称 描述 type() 返回参数的数据类型 dtype 返回数组中元素的数据类型 astype() 对数据类型 ...
- type/dtype/astype的作用
1.type():可以接受任何数据结构,并返回数据结构的类型,例:list,dict,set,numpy.ndarray 2.dtype:调用有限制,数据结构类型内必须只包含一种数据类型,list,d ...
最新文章
- 源文件封装为IP的步骤
- github javaguide_GitHub上收获Star数排名前10的Java项目
- VLAN+DHCP(1)(附抓包)
- 如何解决SSL/TLS握手过程中失败的错误?
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
- MyBatis-Plus 快速开始及详测 SpringBoot 集成Mybatis-Plus
- plupload+artdialog实现多平台文件上传
- 如何在使用Retry之后,Jenkins能够准确发送邮件的脚本
- java递归统计一个文件夹含子文件夹里文件不同后缀的出现次数
- Jenkins 2.322 安装 自定义插件
- Android测量图像中物体大小,android – 加载图像后测量ImageView
- pic单片机 c语言开发环境,《PIC单片机开发环境入门》.pdf
- 定位弹窗软件----找到真凶并做后续防御
- 行测-判断推理-图形推理-样式规律-黑白运算
- Tensorflow图像处理相关操作
- java基于ssm+mysql学生课程表现作业评价系统
- 为什么微信连接不上服务器失败怎么回事啊,微信为什么一直提示连接失败请检查网络设置...
- PostgreSQL 14 pageinspect新增gist索引支持
- The error may exist in bshr/mapper/PfmMapper.xml ### The error may involve defaultParameterMap
- 学习率设置的学问(如何设置学习率)