tensorflow.python.framework.tensor_shape.TensorShape 类
TensorShape 是tensorflow中关于张量shape的类(class).
使用示例如下:
import tensorflow.compat.v1 as tf
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import constant_optensor_test1=[10,10,10]
tensor_test2 = [None,10,10]p1 = tensor_shape.as_shape(tensor_test1) # 得到的是一个类实例,该类实例包含一个属性,是 tensor_test1 的value
const = constant_op.constant(p1.as_list())print("type(p1) = ",type(p1))
print("p1 = ",p1) # 使用p1时会自动调用p1中的value属性
print("p1.is_fully_defined() = ",p1.is_fully_defined())# is_fully_defined 是 TensorShape 类的一个内部函数
print("p1.ndims = ",p1.ndims) # ndims 也是TensorShape的一个属性值
print("p1.as_list() = ",p1.as_list()) # 把TensorShape的value属性转换成python中的list类型
print("const = ",const)
结果如下:
type(p1) = <class 'tensorflow.python.framework.tensor_shape.TensorShape'>
p1 = (10, 10, 10)
p1.is_fully_defined() = True
p1.ndims = 3
p1.as_list() = [10, 10, 10]
const = Tensor("Const:0", shape=(3,), dtype=int32)
tensorflow.python.framework.tensor_shape.TensorShape 类相关推荐
- tensorflow.python.framework.tensor_shape.is_fully_defined()
is_fully_defined() 是tensorflow中tensor_shape下的一个函数,用于判断tensor_shape中的元素是不是全部已知. 举例如下: import tensorfl ...
- tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
nohup python train_rcnn.py & 进行目标检测模型的训练,绝大部分情况下开始甚至好一段时间都OK, 可是,,,, 训练过程中,有时候训练刚开始,有时候训练经过了几个小时 ...
- 解决报错:tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm.
早上在使用tensorflow时报了下面的错: 2019-04-10 10:19:31.648250: I tensorflow/core/platform/cpu_feature_guard.cc: ...
- tensorflow.python.framework.errors_impl.DataLossError:
tensorflow.python.framework.errors_impl.DataLossError: tensorflow.python.framework.errors_impl.DataL ...
- c1083 “tensorflow/python/framework/c pp_shape_inference.pb.h”
win10编译TensorFlow1.8时报错: c1083 "tensorflow/python/framework/c pp_shape_inference.pb.h" 参考这 ...
- 改正错误:tensorflow.python.framework.errors_impl.NotFoundError: FindFirstFile failed for: ...
执行训练的时候,经常出现这种错误: tensorflow.python.framework.errors_impl.NotFoundError: FindFirstFile failed for: / ...
- 成功解决tensorflow.python.framework.errors_impl.NotFoundError: FindFirstFile failed for: ../checkpoints
成功解决tensorflow.python.framework.errors_impl.NotFoundError: FindFirstFile failed for: ../checkpoints ...
- tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm.的一种解决方法
2021-03-23 使用tensorflow构建卷积神经网络训练时出现这个错误tensorflow.python.framework.errors_impl.UnknownError: Faile ...
- Debug Tensorflow: tensorflow.python.framework.errors_impl.InvalidArgumentError: OpKernel ‘ConcatV2‘
环境 Ubuntu 18.04 Tensorflow-gpu 2.4 报错 Traceback (most recent call last):File "nn/cnn.py", ...
最新文章
- linux 批量替换所有文件中包含的字符串
- Apache+tomcat+mod_jk+centos6.2负载均衡集群配置--转载
- 递归与分治——子集问题
- 用Elasticsearch代替数据库存储日志方式
- 阿里云DDoS高防 - 访问与攻击日志实时分析(三)
- 普通html和vue单选框的样式,vue2实现自定义样式radio单选框
- 有关VIM的一些笔记
- 心疼还在用Facebook的你一秒,Snapchat才是未来
- 销售管理c语言程序设计,C语言课程设计销售管理系统
- Vidmore Player for Mac(多功能蓝光播放器)
- oracle数据库驱动下载(ojdbc)
- php扫描图片条形码,php如何生成条形码图片(附代码)
- 牛牛牛!正则阿拉伯数字变中国大写
- 怎么把PDF转换成Word?2种转Word方法技巧
- 小米路由器 mini 有线中继设置教程
- 使用Python对淘宝用户行为进行数据分析
- 初等数论【整除性篇】之习题证明
- CocosCreator报:Maximum call stack size exceeded 的问题
- ios播放视频demo
- Yapi测试插件--cross-request
热门文章
- import python settings from_python settings 中通过字符串导入模块
- mysql忘记命令后半部分_MySQL常用命令
- matlab噪声 方差_产生多种分布的热噪声信号
- 全局中断_【安全圈】微软更新造成Office 365等多个在线服务中断!
- 主键和索引哪个快_字节一面,被连问 MySQL 索引,脸都问绿了。。。
- 鸽主姓名查询成绩_SQL学习之旅-Select简单查询
- c+const_如何在C ++中使用const? 初学者指南
- linux基本命令示例_Linux ps命令– 20个真实示例
- aws lambda_AWS API Gateway和AWS Lambda示例
- Java关闭挂钩– Runtime.addShutdownHook()