未验证 提交 aadd81b6 编写于 作者: L lvmengsi 提交者: GitHub

Fix gradients (#20857)

* fix_gradients

* fix_gradients, test=develop
上级 03ba0fda
......@@ -1247,9 +1247,13 @@ def calc_gradient(targets, inputs, target_gradients=None, no_grad_set=None):
target = targets[i]
if grad is None:
grad_name = _append_grad_suffix_(target.name)
target_shape = paddle.fluid.layers.shape(target)
target_shape = target.name + '_shape'
block.desc.append_op().copy_from(
_create_op_desc_("shape", {'Input': [target.name]},
{"Out": [target_shape]}, {}))
input_grad_names_set.add(target_shape)
op_desc = _create_op_desc_("fill_constant",
{"ShapeTensor": [target_shape.name]},
{"ShapeTensor": [target_shape]},
{"Out": [grad_name]}, {
"shape": target.shape,
"value": 1.0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册