tf.cast()用法总结
概述
tf.cast()函数用于执行tensorflow中张量数据类型转换。
用法
tf.cast(x, dtype, name=None)
1.x:待转换的数据(张量)
2.dtype:目标数据类型
3.name:可选参数,定义操作的名称
数据类型
数据类型 | Python 类型 | 说明 |
---|---|---|
DT_FLOAT | tf.float32 | 32 位浮点数. |
DT_DOUBLE | tf.float64 | 64 位浮点数. |
DT_INT64 | tf.int64 | 64 位有符号整型. |
DT_INT32 | tf.int32 | 32 位有符号整型. |
DT_INT16 | tf.int16 | 16 位有符号整型. |
DT_INT8 | tf.int8 | 8 位有符号整型. |
DT_UINT8 | tf.uint8 | 8 位无符号整型. |
DT_STRING | tf.string | 可变长度的字节数组.每一个张量元素都是一个字节数组. |
DT_BOOL | tf.bool | 布尔型. |
DT_COMPLEX64 | tf.complex64 | 由两个32位浮点数组成的复数:实数和虚数. |
DT_QINT32 | tf.qint32 | 用于量化Ops的32位有符号整型. |
DT_QINT8 | tf.qint8 | 用于量化Ops的8位有符号整型. |
DT_QUINT8 | tf.quint8 | 用于量化Ops的8位无符号整型. |
例子
import tensorflow as tft1 = tf.Variable([1,2,3,4,5])
t2 = tf.cast(t1, dtype=tf.float32)print(t1)
print(t2)tf.compat.v1.disable_eager_execution()
sess= tf.compat.v1.Session()
hello = tf.constant(t2)
print(sess.run(hello))
希望这篇文章对大家的学习有所帮助!
tf.cast()用法总结相关推荐
- tf.cast()数据类型转换
tf.cast()函数的作用是执行 tensorflow 中张量数据类型转换,比如读入的图片如果是int8类型的,一般在要在训练前把图像的数据格式转换为float32. cast定义: cast(x, ...
- tf.cast() 张量数据类型转换
tf.cast() 数据类型转换 import tensorflow as tf t1 = tf.Variable([1,2,3,4,5]) # 生成张量 t1 <tf.Variable 'Va ...
- TF:tensorflow框架中常用函数介绍—tf.Variable()和tf.get_variable()用法及其区别
TF:tensorflow框架中常用函数介绍-tf.Variable()和tf.get_variable()用法及其区别 目录 tensorflow框架 tensorflow.Variable()函数 ...
- tf.cast()类型转换函数
tf.cast(x, dtype, name=None) 参数 x:输入 dtype:转换目标类型 name:名称 返回:Tensor 例子: import tensorflow as tfa = [ ...
- tf.cast() 数据类型转换
tf.cast()函数的作用是执行 tensorflow 中张量数据类型转换,比如读入的图片如果是int8类型的,一般在要在训练前把图像的数据格式转换为float32. cast定义:cast(x, ...
- tf.cast()函数介绍和示例
tf.cast()函数介绍和示例 tf.cast(x, dtype, name=None) 释义:数据类型转换 x,输入张量 dtype,转换数据类型 name,名称 示例: import tenso ...
- Sql中CAST用法介绍
1.cast用法简介: CAST (expression AS data_type) 参数说明: expression:任何有效的SQServer表达式. AS:用于分隔两个参数,在AS之前的是要处理 ...
- tf.estimator用法
estimator:估算器 tf.estimator -----一种高级TensorFlow API.估算器封装以下操作: 训练(training) 评价(evaluation) 预测(predict ...
- Enumerable.Cast用法
Enumerable.Cast用法 前言 一.使用示例 二.Cast在DataTable中的使用 参考文献 前言 将IEnumerable 结合中的元素转换成指定类型 一.使用示例 public st ...
最新文章
- 学Java需要下载什么软件?都有什么作用?
- 【2014】【辛星】【php】【秋季】【2】第一个php程序
- Vue的组件为什么要export default
- spring boot: GlobalDefaultExceptionHandler方法内的友好错误提示,全局异常捕获
- jqGrid文字根据表格大小自动换行
- 【EF学习笔记09】----------使用 EntityState 枚举标记实体状态,实现增删改查
- Ubuntu14.04安装pip及配置
- 百度地图API实现地图应用
- python finally的作用_Python finally
- androidstudio 评论栏_android-studio 添加没有菜单栏和actionBar的模板
- HTTPS协议的简述
- Go 语言之 defer 的前世今生
- 虚拟机备份克隆导致SQL SERVER 出现IO错误案例
- python执行shell脚本报错_详解python执行shell脚本创建用户及相关操作
- Logisim实验一
- Unity渲染管线,初探SRP
- 認識新一代標準色域Rec.BT.2020
- Ubuntu环境下挂载新硬盘
- java -cp 的使用
- AAAI2020|Asymmetric Co-Teaching for Unsupervised Cross-Domain Person Re-Identification