From d1a691733b1be0a266b6b4bb9535ea1a9b729075 Mon Sep 17 00:00:00 2001 From: guosheng Date: Wed, 2 Aug 2017 16:17:20 +0800 Subject: [PATCH] fix bug on ClipLayer test in test_LayerGrad --- paddle/gserver/tests/test_LayerGrad.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/gserver/tests/test_LayerGrad.cpp b/paddle/gserver/tests/test_LayerGrad.cpp index c19bcc153d2..c726e5a74ee 100644 --- a/paddle/gserver/tests/test_LayerGrad.cpp +++ b/paddle/gserver/tests/test_LayerGrad.cpp @@ -1907,8 +1907,10 @@ TEST(Layer, ClipLayer) { config.inputDefs.push_back({INPUT_DATA, "input", size, 0}); LayerInputConfig* input = config.layerConfig.add_inputs(); ClipConfig* layerConf = input->mutable_clip_conf(); - layerConf->set_min(std::rand() / (double)RAND_MAX); - layerConf->set_max(std::rand() / (double)RAND_MAX); + double p1 = std::rand() / (double)RAND_MAX; + double p2 = std::rand() / (double)RAND_MAX; + layerConf->set_min(std::min(p1, p2)); + layerConf->set_max(std::max(p1, p2)); for (auto useGpu : {false, true}) { testLayerGrad(config, "clip", batchSize, false, useGpu, false); } -- GitLab