From 9ecc54a11b61e09c3c503b51049394e61f8e1fa3 Mon Sep 17 00:00:00 2001 From: Yibing Liu Date: Wed, 24 Jan 2018 09:00:03 -0800 Subject: [PATCH] Remove redundant code in unit test --- paddle/operators/lstmp_op.cc | 2 +- paddle/operators/lstmp_op.h | 2 +- python/paddle/v2/fluid/tests/test_lstmp_op.py | 60 +++---------------- 3 files changed, 11 insertions(+), 53 deletions(-) diff --git a/paddle/operators/lstmp_op.cc b/paddle/operators/lstmp_op.cc index 14469c708d0..c96b30ba353 100644 --- a/paddle/operators/lstmp_op.cc +++ b/paddle/operators/lstmp_op.cc @@ -4,7 +4,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/paddle/operators/lstmp_op.h b/paddle/operators/lstmp_op.h index 9dc37615f0a..ee82d5c10a5 100644 --- a/paddle/operators/lstmp_op.h +++ b/paddle/operators/lstmp_op.h @@ -4,7 +4,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/python/paddle/v2/fluid/tests/test_lstmp_op.py b/python/paddle/v2/fluid/tests/test_lstmp_op.py index 08fc32e1171..f137fc61b38 100644 --- a/python/paddle/v2/fluid/tests/test_lstmp_op.py +++ b/python/paddle/v2/fluid/tests/test_lstmp_op.py @@ -131,7 +131,10 @@ def lstmp( class TestLstmpOp(OpTest): - def set_argument(self): + def reset_argument(self): + pass + + def setUp(self): self.lod = [[0, 2, 5, 7]] # hidden size self.D = 16 @@ -147,8 +150,7 @@ class TestLstmpOp(OpTest): self.is_reverse = False self.use_peepholes = True - def setUp(self): - self.set_argument() + self.reset_argument() self.op_type = 'lstmp' T = self.lod[0][-1] @@ -212,19 +214,8 @@ class TestLstmpOp(OpTest): class TestLstmpOpHasInitial(TestLstmpOp): - def set_argument(self): - self.lod = [[0, 2, 5, 7]] - self.D = 16 - self.P = 5 - - self.act_gate = 'sigmoid' - self.act_cell = 'tanh' - self.act_cand = 'tanh' - self.act_proj = self.act_cell - + def reset_argument(self): self.has_initial_state = True - self.is_reverse = True - self.use_peepholes = True def test_check_grad(self): # TODO(qingqing) remove folowing lines after the check_grad is refined. @@ -313,52 +304,19 @@ class TestLstmpOpHasInitial(TestLstmpOp): class TestLstmpOpRerverse(TestLstmpOp): - def set_argument(self): - self.lod = [[0, 2, 5, 7]] - self.D = 16 - self.P = 10 - - self.act_gate = 'sigmoid' - self.act_cell = 'tanh' - self.act_cand = 'tanh' - self.act_proj = self.act_cell - - self.has_initial_state = False + def reset_argument(self): self.is_reverse = True - self.use_peepholes = True class TestLstmpOpNotUsePeepholes(TestLstmpOp): - def set_argument(self): - self.lod = [[0, 2, 5, 7]] - self.D = 16 - self.P = 10 - - self.act_gate = 'sigmoid' - self.act_cell = 'tanh' - self.act_cand = 'tanh' - self.act_proj = self.act_cell - - self.has_initial_state = False - self.is_reverse = False + def reset_argument(self): self.use_peepholes = False class TestLstmpOpLinearProjection(TestLstmpOp): - def set_argument(self): - self.lod = [[0, 2, 5, 7]] - self.D = 16 - self.P = 10 - - self.act_gate = 'sigmoid' - self.act_cell = 'tanh' - self.act_cand = 'tanh' + def reset_argument(self): self.act_proj = 'identity' - self.has_initial_state = False - self.is_reverse = False - self.use_peepholes = True - if __name__ == '__main__': unittest.main() -- GitLab