From e60eb1eacdac476b52cbd029660249fe709b7196 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Thu, 16 Nov 2017 00:45:36 +0800 Subject: [PATCH] fix unitest --- .../v2/{framework => fluid}/tests/test_nce.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) rename python/paddle/v2/{framework => fluid}/tests/test_nce.py (86%) diff --git a/python/paddle/v2/framework/tests/test_nce.py b/python/paddle/v2/fluid/tests/test_nce.py similarity index 86% rename from python/paddle/v2/framework/tests/test_nce.py rename to python/paddle/v2/fluid/tests/test_nce.py index 8b1e7a6bb53..82978f2d230 100644 --- a/python/paddle/v2/framework/tests/test_nce.py +++ b/python/paddle/v2/fluid/tests/test_nce.py @@ -55,10 +55,10 @@ class TestNCE(OpTest): 'sampled_labels': range(num_sampled_classes) } self.inputs = { - 'X': input, + 'Input': input, 'Label': labels, - 'W': weight, - 'B': bias, + 'Weight': weight, + 'Bias': bias, 'SampleWeight': sample_weight } @@ -66,11 +66,12 @@ class TestNCE(OpTest): self.generate_data(5, 5, 4, 1, 2) def compute(self): - out = nce(self.inputs['X'], self.inputs['W'], self.inputs['B'], - self.inputs['SampleWeight'], self.inputs['Label'], - self.attrs['num_classes'], self.attrs['num_sampled_classes']) + out = nce(self.inputs['Input'], self.inputs['Weight'], + self.inputs['Bias'], self.inputs['SampleWeight'], + self.inputs['Label'], self.attrs['num_classes'], + self.attrs['num_sampled_classes']) self.outputs = { - 'Out': out[0], + 'Cost': out[0], 'SampleLogits': out[1], 'SampleLabels': out[2] } @@ -84,7 +85,8 @@ class TestNCE(OpTest): self.check_output() def test_check_grad(self): - self.check_grad(["X", "W", "B"], "Out", max_relative_error=0.02) + self.check_grad( + ["Input", "Weight", "Bias"], "Cost", max_relative_error=0.02) class TestNCECase1(TestNCE): -- GitLab