sequence_softmax operator bug
Created by: zlinker
System information -PaddlePaddle version: 1.7
Description sequence_softmax here should not accumulate exp values directly, which can cause overflow.
here is a demo:
def network():
data = fluid.layers.data("data", shape=[-1, 1], dtype="float32")
output = fluid.layers.sequence_softmax(data)
return output
seq_softmax = network()
data = fluid.create_lod_tensor(np.array([1, 2, 3, 4000], dtype="float32"), [[4]], fluid.CPUPlace())
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())
result = exe.run(feed={"data": data}, fetch_list=[seq_softmax], return_numpy=False)
print(np.array(result)
output :
[ 0. 0. 0. nan]