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 不看 ...
随机推荐
- (转)MyBatis & MyBatis Plus
(二期)3.mybatis与mybatis plus [课程三]mybatis ...运用.xmind0.1MB [课程三]mybatis...机制.xmind0.2MB [课程三]mybatis与j ...
- spring boot 多数据源分布式事务处理
有参考文章 ,但是自己没有测试.
- UVa 11235 频繁出现的数值
https://vjudge.net/problem/UVA-11235 题意: 给出一个非降序排列的整数数组a1,a2,...,an,你的任务是对于一系列询问(i,j),回答ai,ai+1,...a ...
- MVC ---- 理解学习Func用法
//Func用法 public static class FuncDemo{ public static void TestFunc(){ //数据源 List<User> usList ...
- 【Python】【fmt】
[练习] #练习1:format print(format(3.44444,'.3e')) #3.444e+00 #练习2:findall() & finditer()import ...
- Cocos2d-x学习笔记(一)环境搭建与项目创建
可运行的代码可以说明一切问题. 环境需安装VS201x + Python2.7 + Cocos2d-x-2.2.5.(Linux下参考链接:http://www.cocos2d-x.org/wiki/ ...
- 内存溢出和内存泄漏 mark下
https://jingyan.baidu.com/article/495ba841e4423438b30edeb5.html https://www.cnblogs.com/hyh-test/p/8 ...
- threejs和particles.js
particles.js 在线配置的东西: http://vincentgarreau.com/particles.js/ https://threejs.org/ http://thehuub.co ...
- Python 爬虫-正则表达式
2017-07-27 13:52:08 一.正则表达式的概念 (1)正则表达式是用来简洁表达一组字符串的表达式,最主要应用在字符串匹配中. 正则表达式是用来简洁表达一组字符串的表达式 正则表达式是一 ...
- ASCII码、ISO8859-1、Unicode、GBK和UTF-8 的区别
为什么需要编码? 计算机中最小的存储单位是字节(byte),一个字节所能表示的字符数又有限,1byte=8bit,一个字节最多也只能表示255个字符,而世界上的语种又多,都有各种不同的字符,无法用一个 ...