PaddlePaddle / Research

novel deep learning research works with PaddlePaddle
Apache License 2.0
1.72k stars 788 forks source link

change loss.numpy()[0] to float(loss) to adapt 0D #298

Closed zhwesky2010 closed 1 year ago

zhwesky2010 commented 1 year ago

loss正确的语义为0D Tensor,其shape为[],当前使用了shape为[1]替代,也就是向量Tensor:

在进行升级为0D后,loss.numpy()[0] 的写法不再使用,将其改变为 float(loss) 的写法,在升级前(shape为[1])、升级后(shape为[])下都同样适用,兼容改法。