smooth l1 loss替换huber loss的时候,是不是要修改下什么呀? 我参考官方文档替换了下,最后loss反传会报错。
报错信息:
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.
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_onesthanks for qingqing's help.
2条答案
按热度按时间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.
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.