hash函数使用出错
Created by: duanfz2314
官方代码: import paddle.fluid as fluid import numpy as np place = fluid.core.CPUPlace()
构建网络
x = fluid.layers.data(name="x", shape=[1], dtype="int32", lod_level=1) res = fluid.layers.hash(name="res",input=x, hash_size=1000, num_hash=4)
创建CPU执行器
exe = fluid.Executor(place) exe.run(fluid.default_startup_program()) in1 = np.array([[1,2],[3,4]]).astype("int32") print(in1) x_i = fluid.core.LoDTensor() x_i.set(in1,place) x_i.set_recursive_sequence_lengths([[0,2]]) res = exe.run(fluid.default_main_program(), feed={'x':x_i}, fetch_list=[res], return_numpy=False) print(np.array(res[0])) 报错: InvalidArgumentError: The Tensor in the hash Op's Input Variable X(creative_id) is not initialized. [Hint: Expected t->IsInitialized() == true, but received t->IsInitialized():0 != true:1.] at (/paddle/paddle/fluid/framework/operator.cc:1264) [operator < hash > error]