From 68bfc3ff963474e12c8af1c3575128b0acac90ed Mon Sep 17 00:00:00 2001 From: dongzhihong Date: Wed, 9 Aug 2017 21:02:51 +0800 Subject: [PATCH] "add python test" --- .../v2/framework/tests/test_rowwise_add_op.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/paddle/v2/framework/tests/test_rowwise_add_op.py b/python/paddle/v2/framework/tests/test_rowwise_add_op.py index e957dd6b3..1b27f54f1 100644 --- a/python/paddle/v2/framework/tests/test_rowwise_add_op.py +++ b/python/paddle/v2/framework/tests/test_rowwise_add_op.py @@ -1,6 +1,7 @@ import unittest -from op_test_util import OpTestMeta import numpy as np +from op_test_util import OpTestMeta +from gradient_checker import GradientChecker, create_op class TestRowwiseAddOp(unittest.TestCase): @@ -15,6 +16,16 @@ class TestRowwiseAddOp(unittest.TestCase): self.outputs = {'Out': np.add(self.inputs['X'], self.inputs['b'])} +class RowwiseAddGradOpTest(GradientChecker): + def test_rowwise_add(self): + op = create_op("rowwise_add") + inputs = { + "X": np.random.uniform(0.1, 1, [10, 10]).astype("float32"), + "b": np.random.uniform(0.1, 1, [10, 1]).astype("float32") + } + self.check_grad(op, inputs, set("X", "b"), "Out") + + #TODO(dzh): rowwise_grad check if __name__ == '__main__': -- GitLab