From 92f4a522a09a1daa23a546fb043b607969573c57 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Sat, 19 Oct 2019 18:49:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90cherry-pick=E3=80=91=20fix=20fill=5Fco?= =?UTF-8?q?nstant=20shape=20with=20-1=20and=20enhance=20cross=5Fentropy=20?= =?UTF-8?q?test=3Drelease/1.6=20(#20722)=20(#20728)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- paddle/fluid/operators/cross_entropy_op.cc | 4 ++-- python/paddle/fluid/backward.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/cross_entropy_op.cc b/paddle/fluid/operators/cross_entropy_op.cc index 66986e14d8..8a80619f66 100644 --- a/paddle/fluid/operators/cross_entropy_op.cc +++ b/paddle/fluid/operators/cross_entropy_op.cc @@ -136,8 +136,8 @@ class CrossEntropyGradientOpBase : public framework::OperatorWithKernel { "Input(Y@Grad) and Input(Y) should have the same rank."); bool check = true; - if ((!ctx->IsRuntime()) && (framework::product(x_dims) <= 0 || - framework::product(label_dims) <= 0)) { + if ((!ctx->IsRuntime()) && + (framework::product(x_dims) <= 0 || framework::product(dy_dims) <= 0)) { check = false; } diff --git a/python/paddle/fluid/backward.py b/python/paddle/fluid/backward.py index 1306fbc574..860e7092f6 100644 --- a/python/paddle/fluid/backward.py +++ b/python/paddle/fluid/backward.py @@ -1251,7 +1251,7 @@ def calc_gradient(targets, inputs, target_gradients=None, no_grad_set=None): op_desc = _create_op_desc_("fill_constant", {"ShapeTensor": [target_shape.name]}, {"Out": [grad_name]}, { - "shape": [], + "shape": target.shape, "value": 1.0, "dtype": target.dtype, }) -- GitLab