推理阶段报错
Created by: ARDUJS
大哥,Help !!!
环境
- python = 3.75
- paddlepaddle = 1.7.2
问题
推理阶段报错
这是啥错误,貌似是我自定义op操作位置报错
OP操作代码
def seq_gather(x):
seq,idxs = x
# print(type(idxs))
# print(idxs)
#idxs=np.cast(idxs,'int64')
idxs=idxs.astype('int64')
#idxs = layers.cast(idxs,'int64')
batch_idxs=np.arange(0,seq.shape[0])
#batch_idxs = layers.range(0,2,1,'int64')
batch_idxs=np.expand_dims(batch_idxs,1)
#batch_idxs = layers.unsqueeze(batch_idxs,[1])
idxs=np.concatenate([batch_idxs,idxs],1)
xxx=[]
for s in idxs:
x=seq[s[0],s[1]]
xxx.append(x)
xxx=np.array(xxx)
#print(xxx)
#np.append(xxx,x)
return xxx#xxx #layers.gather_nd(seq,idxs)
def get_k_infer(x1,x2,x3):
#seq, k1, k2 = x1,x2,x3
seq=np.array(x1)
k1=np.array(x2)
k2=np.array(x3)
k_inter = [np.round(k1*a + k2*(1.0-a)) for a in np.arange(6)/(6-1.0)]
#print(len(k_inter))
k_inter = [seq_gather([seq,k]) for k in k_inter]
#print(len(k_inter))
k_inter = [np.expand_dims(k,1) for k in k_inter]
k_infer = np.concatenate(k_inter,1)
return k_infer
def create_tmp_var(program, name, dtype, shape):
return program.current_block().create_var(name=name, dtype=dtype, shape=shape)
k_infer = create_tmp_var(fluid.default_main_program(), name='k_infer', dtype='float32', shape=[-1, 6, 128])
fluid.layers.py_func(func=get_k_infer, x=(t, k1, k2), out=k_infer, backward_func=None)
t :(batch_size, 256, 128) k1: (batch_size, 1) k2: (batch_size, 1)
训练阶段都是正常的