From 231501fefc0e881a87b469cc2a17c3739cb0f9b3 Mon Sep 17 00:00:00 2001 From: Double_V Date: Tue, 12 Jan 2021 13:28:26 +0800 Subject: [PATCH] fix elugradgrad test fail & error message opt (#30171) * fix elugradgrad test fail and error message opt * fix unitest,test=develop * Update prroi_pool_op.h fix error message * opt message,test=develop * fix ci fail,test=develop --- paddle/fluid/operators/activation_op.h | 2 +- paddle/fluid/operators/prroi_pool_op.h | 19 ++++++++++++------- .../unittests/test_activation_nn_grad.py | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/operators/activation_op.h b/paddle/fluid/operators/activation_op.h index 28329bce6e..6e906d734e 100644 --- a/paddle/fluid/operators/activation_op.h +++ b/paddle/fluid/operators/activation_op.h @@ -1598,7 +1598,7 @@ struct ELUGradGradFunctor : public BaseActivationFunctor { auto dout = framework::EigenVector::Flatten( GET_DATA_SAFELY(dOut, "Output", "DOut", "ELUGradGrad")); dx.device(*d) = ddx * dout * static_cast(alpha) * x.exp() * - (x < static_cast(0)).template cast(); + (x <= static_cast(0)).template cast(); } if (ddOut) { diff --git a/paddle/fluid/operators/prroi_pool_op.h b/paddle/fluid/operators/prroi_pool_op.h index 5ec846c147..11ecff8845 100644 --- a/paddle/fluid/operators/prroi_pool_op.h +++ b/paddle/fluid/operators/prroi_pool_op.h @@ -293,19 +293,24 @@ class CPUPRROIPoolOpKernel : public framework::OpKernel { } else { PADDLE_ENFORCE_EQ(rois->lod().empty(), false, platform::errors::InvalidArgument( - "the lod of Input ROIs should not be empty when " + "The lod of Input ROIs should not be empty when " "BatchRoINums is None!")); auto rois_lod = rois->lod().back(); int rois_batch_size = rois_lod.size() - 1; - PADDLE_ENFORCE_EQ( - rois_batch_size, batch_size, - platform::errors::InvalidArgument("the rois_batch_size and input(X) " - "batch_size should be the same.")); + PADDLE_ENFORCE_EQ(rois_batch_size, batch_size, + platform::errors::InvalidArgument( + "The rois_batch_size and input(X)'s " + "batch_size should be the same but received" + "rois_batch_size: %d and batch_size: %d", + rois_batch_size, batch_size)); int rois_num_with_lod = rois_lod[rois_batch_size]; PADDLE_ENFORCE_EQ( rois_num_with_lod, rois_num, - platform::errors::InvalidArgument( - "the rois_num from input and lod must be the same")); + platform::errors::InvalidArgument("The rois_num from input should be " + "equal to the rois_num from lod, " + "but received rois_num from input: " + "%d and the rois_num from lod: %d.", + rois_num_with_lod, rois_num)); // calculate batch id index for each roi according to LoD for (int n = 0; n < rois_batch_size; ++n) { diff --git a/python/paddle/fluid/tests/unittests/test_activation_nn_grad.py b/python/paddle/fluid/tests/unittests/test_activation_nn_grad.py index 9c5f580d81..cfa487a835 100644 --- a/python/paddle/fluid/tests/unittests/test_activation_nn_grad.py +++ b/python/paddle/fluid/tests/unittests/test_activation_nn_grad.py @@ -78,9 +78,9 @@ class TestLeakyReluDoubleGradCheck(unittest.TestCase): class TestELUDoubleGradCheck(unittest.TestCase): @prog_scope() def func(self, place): - shape = [2, 3, 6, 6] + shape = [2, 4, 4, 4] eps = 1e-6 - alpha = 1.1 + alpha = 0.2 dtype = np.float64 SEED = 0 -- GitLab