Paddle smooth l1 loss替换huber loss的时候,是不是要修改下什么呀? 我参考官方文档替换了下,最后loss反传会报错,

kq4fsx7k  于 2021-11-29  发布在  Java
关注(0)|答案(2)|浏览(351)

smooth l1 loss替换huber loss的时候,是不是要修改下什么呀? 我参考官方文档替换了下,最后loss反传会报错。

报错信息:

nwlls2ji

nwlls2ji1#

@takecareofbigboss Please see doc http://www.paddlepaddle.org/documentation/docs/zh/1.4/api_cn/layers_cn.html#huber-loss for huber loss, the last dim must be 1.

pxq42qpu

pxq42qpu2#

this problem has been solved, and the solution is:
cost = fluid.layers.huber_loss(fluid.layers.reshape(outputs_masked, shape=[-1, 1]), fluid.layers.reshape(pts_masked, shape=[-1, 1]), 3.0)
cost = fluid.layers.reshape(cost, shape=[-1, args.n_pt*2])
cost = fluid.layers.reduce_sum(cost, dim=1)
cost = fluid.layers.reshape(cost, shape=[-1, 1])
cost = cost / num_ones
thanks for qingqing's help.

相关问题