tensorflow中的数据类型dtype用法说明
作者:知了不知蝉鸣惊 时间:2023-08-28 05:44:30
Tensorflow中,主要有以下几种数据类型(dtype),在旧版本中,不用加tf也能使用。
有符号整型
tf.int8:8位整数。
tf.int16:16位整数。
tf.int32:32位整数。
tf.int64:64位整数。
无符号整型
tf.uint8:8位无符号整数。
tf.uint16:16位无符号整数。
浮点型
tf.float16:16位浮点数。
tf.float32:32位浮点数。
tf.float64:64位浮点数。
tf.double:等同于tf.float64。
字符串型
tf.string:字符串。
布尔型
tf.bool:布尔型。
复数型
tf.complex64:64位复数。
tf.complex128:128位复数。
补充:tensorflow及numpy的数据类型对象Dtype总结
1.dtyte与astype
dtype:查看数据类型
astype:转换数据类型
2.tensorlow数据类型对象Dtype
名称 | 描述 |
---|---|
tf.float16 | 16位半精度浮点 |
tf.float32 | 32位单精度浮点 |
tf.float64 | 64位双精度浮点 |
tf.bfloat16 | 16位截断浮点 |
tf.complex64 | 64位单精度复数 |
tf.complex128 | 128位双精度复数 |
tf.int8 | 8位有符号整数 |
tf.uint8 | 8位无符号整数 |
tf.uint16 | 16位无符号整数 |
tf.int16 | 16位有符号整数 |
tf.int32 | 32位有符号整数 |
tf.int64 | 64位有符号整数 |
tf.bool | 布尔值 |
tf.string | 字符串 |
tf.qint8 | 量化的8位带符号整数 |
tf.quint8 | 量化的8位无符号整数 |
tf.qint16 | 量化的16位有符号整数 |
tf.quint16 | 量化的16位无符号整数 |
tf.qint32 | 量化的32位有符号整数 |
tf.as_dtype()函数将numpy类型和字符串类型名称转换为DType对象。
3.numpy数据类型对象dtype
名称 | 描述 |
---|---|
np.bool_ | 布尔型数据类型 |
np.int_ | 默认的整数类型 |
np.intc | 与 C 的 int 类型一样,一般是 int32 或 int 64 |
np.intp | 用于索引的整数类型,一般是 int32 或 int64 |
np.int8 | 8位整数即1字节(-128 to 127) |
np.int16 | 16位整数(-32768 to 32767) |
np.int32 | 32位整数(-2147483648 to 2147483647) |
np.int64 | 64位整数(-9223372036854775808 to 9223372036854775807) |
np.uint8 | 8位无符号整数(0 to 255) |
np.uint16 | 16位无符号整数(0 to 65535) |
np.uint32 | 32位无符号整数(0 to 4294967295) |
np.uint64 | 64位无符号整数(0 to 18446744073709551615) |
np.float_ | float64 简写,即64位双精度浮点数 |
np.float16 | 16位半精度浮点数,包括:1 个符号位,5 个指数位,10 个尾数位 |
np.float32 | 32位 单精度浮点数,包括:1 个符号位,8 个指数位,23 个尾数位 |
np.float64 | 64位双精度浮点数,包括:1 个符号位,11 个指数位,52 个尾数位 |
np.complex_ | complex128 简写,即 128 位复数 |
np.complex64 | 复数,表示双 32 位浮点数(实数部分和虚数部分) |
np.complex128 | 复数,表示双 64 位浮点数(实数部分和虚数部分) |
来源:https://blog.csdn.net/promisejia/article/details/80806984
标签:tensorflow,dtype
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
为2021年的第一场雪锦上添花:用matplotlib绘制雪花和雪景
2022-02-01 23:19:56
![](https://img.aspxhome.com/file/2023/2/130832_0s.png)
巧用JDBC实现对MySQL的“增删改查”
2008-12-31 15:12:00
golang通过node_exporter监控GPU及cpu频率、温度的代码
2024-02-04 14:53:22
![](https://img.aspxhome.com/file/2023/5/114835_0s.png)
MySQL 5.0触发器参考教程第1/4页
2024-01-23 17:03:58
JS组件Bootstrap实现图片轮播效果
2024-04-22 13:03:11
![](https://img.aspxhome.com/file/2023/0/135900_0s.gif)
如何防范利用刷新来“作弊”的计数器?
2009-11-22 17:18:00
mysql中全连接full join...on...的用法说明
2024-01-13 19:44:22
利用MySQL主从配置实现读写分离减轻数据库压力
2024-01-18 10:35:07
![](https://img.aspxhome.com/file/2023/9/70389_0s.png)
Python基础之字典常见操作经典实例详解
2022-09-01 15:59:18
mysql备份脚本 mysqldump使用方法详解
2024-01-24 12:27:04
Python编程pygal绘图实例之XY线
2021-02-17 10:42:10
![](https://img.aspxhome.com/file/2023/2/84112_0s.png)
python利用tkinter实现屏保
2022-01-26 05:39:51
tensorflow实现从.ckpt文件中读取任意变量
2023-01-04 15:39:40
MySQL语句汇总整理
2024-01-17 08:22:33
![](https://img.aspxhome.com/file/2023/8/121258_0s.png)
SQL SERVER 2008 无法附加数据库的解决方法
2024-01-18 02:35:50
在for循环中length值是否需要缓存
2023-07-02 05:19:20
Python利用装饰器click处理解析命令行参数
2023-12-23 20:49:05
Python实现的删除重复文件或图片功能示例【去重】
2023-12-25 00:49:07
![](https://img.aspxhome.com/file/2023/6/102846_0s.png)
python对输出的奇数偶数排序实例代码
2023-02-17 17:55:16
matlab 生成.bmp格式的文件
2022-08-06 09:39:09