在将 列表或元组 数据转换成 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].的更多相关文章

  1. 【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= ...

  2. tensorflow报错 tensorflow Resource exhausted: OOM when allocating tensor with shape

    在使用tensorflow的object detection时,出现以下报错 tensorflow Resource exhausted: OOM when allocating tensor wit ...

  3. 显存不够----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 ...

  4. 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 ...

  5. 关于类型为numpy,TensorFlow.tensor,torch.tensor的shape变化以及相互转化

    https://blog.csdn.net/zz2230633069/article/details/82669546 2018年09月12日 22:56:50 一只tobey 阅读数:727   1 ...

  6. ''tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[?]'' 错误分析

    这是tensorflow 一个经常性错误,错误的原因在于:显卡内存不够. 解决方法就是降低显卡的使用内存,途径有以下几种措施: 1 减少Batch 的大小 2 分析错误的位置,在哪一层出现显卡不够,比 ...

  7. TensorFlow OOM when allocating tensor with shape[5000,384707]

    在session范围内不要进行eval()或者convert_to_tensor()操作, 否则会造成OOM,或者报出错误:GraphDef cannot be larger than 2GB usi ...

  8. 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 ...

  9. 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 不看 ...

随机推荐

  1. PHP获取当前页面的网址

    PHP获取当前页面的网址 function GetCurUrl() { $url = 'http://'; if(isset($_SERVER['HTTPS']) AND $_SERVER['HTTP ...

  2. 【核心API开发】Spark入门教程[3]

    本教程源于2016年3月出版书籍<Spark原理.机制及应用> ,在此以知识共享为初衷公开部分内容,如有兴趣,请支持正版书籍. Spark综合了前人分布式数据处理架构和语言的优缺点,使用简 ...

  3. 51nod 1242 斐波那契数列的第N项

    之前一直没敢做矩阵一类的题目 其实还好吧 推荐看一下 : http://www.cnblogs.com/SYCstudio/p/7211050.html 但是后面的斐波那契 推导不是很懂  前面讲的挺 ...

  4. Unity3D学习笔记(六):三角函数和点乘

    三角函数: 概念:用来描述三角形中某个角和对应的三条边的比例关系. 正弦:sin<θ>(sin<theta>)=对边/斜边 余弦:cos<θ>(cos<the ...

  5. iis发布,部署

    1.项目发布:选择iis:文件系统:文件路径:realese 2.iis添加: 3.host文件添加 问题1: 不能在此路径中使用此配置节.如果在父级别上锁定了该节,便会出现这种情况.锁定 在全新安装 ...

  6. Tex: The top-level auxiliary file: *.aux I couldn't open style file IEEEtran.bst 解决方法

    参考: Bibliography is not printed using Kile on Ubuntu Tex: The top-level auxiliary file: *.aux I coul ...

  7. javascript的一些在IE下不支持的函数小结

    // ============ isArray ===============// // isArray function isArray(value){ return Object.prototyp ...

  8. POJ 3164 Command Network(最小树形图模板题+详解)

    http://poj.org/problem?id=3164 题意: 求最小树形图. 思路: 套模板. 引用一下来自大神博客的讲解:http://www.cnblogs.com/acjiumeng/p ...

  9. MongoDB(课时15 数据排序)

    3.4.2.10 数据排序 在MongoDB里数据排序操作使用“sort()”函数,在进行排序的时候可以有两个顺序:升序(1),降序(-1). 范例:排序 db.students.find().sor ...

  10. STL__网上资料

    1. http://bbs.csdn.net/topics/370029802 #include <iostream> #include <limits> #include & ...