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:转换数据类型

tensorflow中的数据类型dtype用法说明

2.tensorlow数据类型对象Dtype

名称描述
tf.float1616位半精度浮点
tf.float3232位单精度浮点
tf.float6464位双精度浮点
tf.bfloat1616位截断浮点
tf.complex6464位单精度复数
tf.complex128128位双精度复数
tf.int88位有符号整数
tf.uint88位无符号整数
tf.uint1616位无符号整数
tf.int1616位有符号整数
tf.int3232位有符号整数
tf.int6464位有符号整数
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.int88位整数即1字节(-128 to 127)
np.int1616位整数(-32768 to 32767)
np.int3232位整数(-2147483648 to 2147483647)
np.int6464位整数(-9223372036854775808 to 9223372036854775807)
np.uint88位无符号整数(0 to 255)
np.uint1616位无符号整数(0 to 65535)
np.uint3232位无符号整数(0 to 4294967295)
np.uint6464位无符号整数(0 to 18446744073709551615)
np.float_float64 简写,即64位双精度浮点数
np.float1616位半精度浮点数,包括:1 个符号位,5 个指数位,10 个尾数位
np.float3232位 单精度浮点数,包括:1 个符号位,8 个指数位,23 个尾数位
np.float6464位双精度浮点数,包括:1 个符号位,11 个指数位,52 个尾数位
np.complex_complex128 简写,即 128 位复数
np.complex64复数,表示双 32 位浮点数(实数部分和虚数部分)
np.complex128复数,表示双 64 位浮点数(实数部分和虚数部分)

来源:https://blog.csdn.net/promisejia/article/details/80806984

标签:tensorflow,dtype
0
投稿

猜你喜欢

  • 为2021年的第一场雪锦上添花:用matplotlib绘制雪花和雪景

    2022-02-01 23:19:56
  • 巧用JDBC实现对MySQL的“增删改查”

    2008-12-31 15:12:00
  • golang通过node_exporter监控GPU及cpu频率、温度的代码

    2024-02-04 14:53:22
  • MySQL 5.0触发器参考教程第1/4页

    2024-01-23 17:03:58
  • JS组件Bootstrap实现图片轮播效果

    2024-04-22 13:03:11
  • 如何防范利用刷新来“作弊”的计数器?

    2009-11-22 17:18:00
  • mysql中全连接full join...on...的用法说明

    2024-01-13 19:44:22
  • 利用MySQL主从配置实现读写分离减轻数据库压力

    2024-01-18 10:35:07
  • Python基础之字典常见操作经典实例详解

    2022-09-01 15:59:18
  • mysql备份脚本 mysqldump使用方法详解

    2024-01-24 12:27:04
  • Python编程pygal绘图实例之XY线

    2021-02-17 10:42:10
  • python利用tkinter实现屏保

    2022-01-26 05:39:51
  • tensorflow实现从.ckpt文件中读取任意变量

    2023-01-04 15:39:40
  • MySQL语句汇总整理

    2024-01-17 08:22:33
  • 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
  • python对输出的奇数偶数排序实例代码

    2023-02-17 17:55:16
  • matlab 生成.bmp格式的文件

    2022-08-06 09:39:09
  • asp之家 网络编程 m.aspxhome.com