源码从这个地方Fork的,AIStudio上运行没问题
https://aistudio.baidu.com/aistudio/projectdetail/78959
但是我下载到本机之后,报出如下错误
C++ Callstacks:
Tensor holds the wrong type, it holds int at [D:\1.4.1\paddle\paddle/fluid/framework/tensor_impl.h:29]
PaddlePaddle Call Stacks:
Windows not support stack backtrace yet.
查看了源码,指向的是如下代码
执行预测
result = exe.run(program=infer_program,
feed={feeded_var_names[0]: tensor_words},
fetch_list=target_var)
所有能够尝试的排错方式都做了,文件名,路径,paddle版本。
整个源码,就是从AIStudio下载的,注解了几行无关紧要的代码。
类型也改过,从int64改为float64,但是报出另外一个错误
Tensor holds the wrong type, it holds double, but desires to be int64_t at [D:\1.5.1\release_cuda97\paddle\paddle/fluid/framework/tensor_impl.h:30]
问题显然不是类型的错误。
系统环境
windows 7 x64
python 3.6.1 x64
paddle 1.4.1,后升级为1.5.1,问题依旧
2条答案
按热度按时间fquxozlt1#
能检查下输入数据类型吗,看是否跟定义的数据类型一致?
看了下代码,
words = fluid.layers.data(name='words', shape=[1], dtype='int64', lod_level=1)
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
但是reader里面:
data, label = line.split('\t')
yield data, label
这里产生的data和label是string类型的,能改成data = int(data), label=int(label) 之后再试下吗
qyuhtwio2#
改了之后类型还是不对
Tensor holds the wrong type, it holds double, but desires to be int64_t at [D:\1.5.1\release_cuda97\paddle\paddle/fluid/framework/tensor_impl.h:30]
PaddlePaddle Call Stacks:
Windows not support stack backtrace yet.
那段代码我看AIStudio里Train和Test里都是line.split('\t')
并没有做数据类型转换,AIStudio跑的通