ValueError: Argument must be a dense tensor:... got shape [6, 60, 160, 3], but wanted [6].
在将 列表或元组 数据转换成 dataset类型时
import numpy as np
import tensorflow as tf
from sklearn.cross_validation import train_test_split
pic_array=np.ones((60,160,3)) #图片的长宽为60*160,每个像素点的由rgb3个值表示像素
pic_txt_array=np.ones((26,4)) #表示单个字母的向量长为26,共4个字母
data_x=[pic_array for i in range(1000)] #1000张图片的集合
data_y=[pic_txt_array for i in range(1000)]#1000长图片对应的字母的集合
#将装着样本的列表 转换成dataset格式
train_dataset=tf.data.Dataset.from_tensor_slices((data_x,data_y))
发生异常:
File "tf_test.py", line 10, in <module>
train_dataset=tf.data.Dataset.from_tensor_slices((data_x,data_y))
File "F:\Program Files\Python35\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 235, in from_tensor_slices
return TensorSliceDataset(tensors)
File "F:\Program Files\Python35\lib\site-packages\tensorflow\python\data\ops\dataset_ops.py", line 1030, in __init__
for i, t in enumerate(nest.flatten(tensors))
........
File "F:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "F:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 441, in make_tensor_proto
_GetDenseDimensions(values)))
ValueError: Argument must be a dense tensor: [array([[[1., 1., 1.],...
...,
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]]])] - got shape [6, 60, 160, 3], but wanted [6].
解决:修改源数据的格式
data_x=np.asarray([pic_array for i in range(1000)]) #1000张图片的集合
data_y=np.asarray([pic_txt_array for i in range(1000)]) #1000长图片对应的字母的集合
ValueError: Argument must be a dense tensor:... got shape [6, 60, 160, 3], but wanted [6].的更多相关文章
- 【tf.keras】Resource exhausted: OOM when allocating tensor with shape [9216,4096] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
运行以下类似代码: while True: inputs, outputs = get_AlexNet() model = tf.keras.Model(inputs=inputs, outputs= ...
- tensorflow报错 tensorflow Resource exhausted: OOM when allocating tensor with shape
在使用tensorflow的object detection时,出现以下报错 tensorflow Resource exhausted: OOM when allocating tensor wit ...
- 显存不够----ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[4096]
ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[4096] 类似问题 h ...
- Resource exhausted: OOM when allocating tensor with shape[3,3,384,384] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0。。。。。
报错信息: OP_REQUIRES failed at assign_op.h:111 : Resource exhausted: OOM when allocating tensor with sh ...
- 关于类型为numpy,TensorFlow.tensor,torch.tensor的shape变化以及相互转化
https://blog.csdn.net/zz2230633069/article/details/82669546 2018年09月12日 22:56:50 一只tobey 阅读数:727 1 ...
- ''tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[?]'' 错误分析
这是tensorflow 一个经常性错误,错误的原因在于:显卡内存不够. 解决方法就是降低显卡的使用内存,途径有以下几种措施: 1 减少Batch 的大小 2 分析错误的位置,在哪一层出现显卡不够,比 ...
- TensorFlow OOM when allocating tensor with shape[5000,384707]
在session范围内不要进行eval()或者convert_to_tensor()操作, 否则会造成OOM,或者报出错误:GraphDef cannot be larger than 2GB usi ...
- OP_REQUIRES failed at conv_ops.cc:386 : Resource exhausted: OOM when allocating tensor with shape..
tensorflow-gpu验证准确率是报错如上: 解决办法: 1. 加入os.environ['CUDA_VISIBLE_DEVICES']='2' 强制使用CPU验证-----慢 2.'batch ...
- OOM when allocating tensor of shape [] and type float [[node conv2d_224/kernel/Initializer/random_uniform/min (defined at ./intances/utils.py:19) ]]
当你们在用模型加载,tensorflow-gpu预测的时候,有没有出现这样的错误?? 经过网上的资料查阅,更多的解释是GPU的显存不足造成的,于是乎,我查看了一下GPU显存:nvidia-smi 不看 ...
随机推荐
- Pandas fillna('Missing')
https://blog.csdn.net/donghf1989/article/details/51167083/ .使用0替代缺失值(当然你可以用任意一个数字代替NaN) df.fillna(0) ...
- POJ1144 Network(割点)题解
Description A Telephone Line Company (TLC) is establishing a new telephone cable network. They are c ...
- Linux deepin 中Jetbrain Idea等软件中文显示异常
解决方案:安装常用的中文字体 # 文鼎宋体[推荐] sudo apt install fonts-arphic-uming # 文鼎楷体[推荐] sudo apt install fonts-arph ...
- redhat7 防火墙设置
查看防火墙的状态# firewall-cmd --staterunning # systemctl stop firewalld //关闭防火墙服务# systemctl start firewa ...
- 【概念、概述】Spark入门教程[1]
本教程源于2016年3月出版书籍<Spark原理.机制及应用> ,如有兴趣,请支持正版书籍. 随着互联网为代表的信息技术深度发展,其背后由于历史积累产生了TB.PB甚至EB级数据量,由于传 ...
- Unity3D学习笔记(十六):Animator新动画
新动画系统: 给模型选择动画类型 普通动画:Generic 人形动画:Humanoid 建立动画控制器 - 在Project右击 - 选择Create-AnimatorContorller 将对应动画 ...
- OpenFlow protocol version 1.0 通信过程
参考 李呈:[原创]OpenFlow通信流程解读 OpenFlow protocol version 1.0 通信过程 通信双方: OpenFlow控制器,OpenFlow交换机. 通信模块: Sec ...
- vue-cli 组件运用
// components ----- helloworld.vue <script> export default { name: 'Hellowworld', props: { //接 ...
- java ShutdownHook介绍与使用
Java程序经常也会遇到进程挂掉的情况,一些状态没有正确的保存下来,这时候就需要在JVM关掉的时候执行一些清理现场的代码.JAVA中的ShutdownHook提供了比较好的方案. JDK提供了Java ...
- ASCII码、ISO8859-1、Unicode、GBK和UTF-8 的区别
为什么需要编码? 计算机中最小的存储单位是字节(byte),一个字节所能表示的字符数又有限,1byte=8bit,一个字节最多也只能表示255个字符,而世界上的语种又多,都有各种不同的字符,无法用一个 ...