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 不看 ...
随机推荐
- sql 题目
1.自增列 通用: ) from table b where b.sid<a.sid) ,* from table a; ,),* from ... 第二个已经有主键自增列的就不可以用了 还有就 ...
- C# WinCE项目 VS2008 单例窗体实现
项目现有主界面FormMain,模板界面FormModel,其余5个子界面皆继承自模板. 现在想要实现在主界面下可以打开任意子界面,并且可以随时关闭.当打开的子窗体未执行Close事件时,要保证每次显 ...
- poj 1523 SPF 无向图求割点
SPF Description Consider the two networks shown below. Assuming that data moves around these network ...
- sqlserver 存入DB中的中文乱码
在war包中的appliation.properties中,配置的数据库连接做了修改,也不知道当初为什么这么改 导致存入DB中的中文是??? testaaa.jdbc.type=mssqltestaa ...
- Python day13文件的读写
# 文件操作 f=open("E:\\1.txt",encoding="GBK")#打开文件 print(f.writable())#是否可写 print(f. ...
- es6模块 nodejs模块和 typescript模块
es6模块 import和export nodejs模块 require和module.exports typescript模块 module和export
- 监督学习--k近邻算法
2017-07-20 15:18:25 k近邻(k-Nearest Neighbour, 简称kNN)学习是一种常用的监督学习方法,其工作机制非常简单,对某个给定的测试样本,基于某种距离度量找出训练集 ...
- C#对GZIP压缩和解压
/// <summary> /// 将Gzip的byte数组读取为字符串 /// </summary> /// <param name="bytes" ...
- HTTP URL 字符转义 字符编码 、 RFC 3986编码规范
一.为什么要编码转义 通常如果一样东西需要编码,说明这样东西并不适合传输.原因多种多样,如Size过大,包含隐私数据,对于Url来说,之所以要进行编码,是因为Url中有些字符会引起歧义. 例如Url参 ...
- [Java学习] Java instanceof 运算符
多态性带来了一个问题,就是如何判断一个变量所实际引用的对象的类型 . C++使用runtime-type information(RTTI),Java 使用 instanceof 操作符. insta ...