对自己传入数据的lodtensor调用op操作时报错说输入不是一个variable
Created by: taojiucheng
def merge_dict(dict, item):
temp= {}
list = ['category', 'item_type', 'layout', 'pos', 'cuid', 'province', 'net_type']
for i in range(len(list)):
if i > 3:
temp[list[i]] = dict[list[i]]
else:
'''
print dict[list[i]]
print item[list[i]]
'''
temp[list[i]] = fluid.layers.sequence_concat(input=[dict[list[i]], item[list[i]]])
return temp
函数的输入是两个字典,需要对不同的key对应的value(是一个lodtensor)进行拼接,concat的输入打印出来是这样的
<paddle.fluid.core.LoDTensor object at 0x7fc70982cd18>
<paddle.fluid.core.LoDTensor object at 0x7fc70982cc38>
输入转成numpy array后是[[1]]、[[1]] 调用op后报错如下:
File "eval_temp.py", line 410, in merge_dict
temp[list[i]] = fluid.layers.sequence_concat(input=[dict[list[i]], item[list[i]]])
File "/home/user/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/layers/nn.py", line 2149, in sequence_concat
out = helper.create_variable_for_type_inference(dtype=helper.input_dtype())
File "/home/user/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 102, in input_dtype
inputs = self.multiple_input(input_param_name)
File "/home/user/paddle_release_home/python/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 64, in multiple_input
raise type_error
TypeError: Input of sequence_concat layer should be Variable or sequence of Variable
函数的输出组织成字典的形式直接通过feed传给exe,想请问下是我使用的方法不对还是什么问题呢?