From 4223ff8c27a8681096ad73659a6ea03441cf3831 Mon Sep 17 00:00:00 2001 From: Liu Yiqun Date: Mon, 11 Sep 2017 07:00:04 +0000 Subject: [PATCH] Correct the key name of "mul" op in FCOp, and add some annotations for debug. --- paddle/operators/fc_op.cc | 4 +++- python/paddle/v2/framework/tests/op_test.py | 8 ++++---- python/paddle/v2/framework/tests/test_fc_op.py | 5 +---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/paddle/operators/fc_op.cc b/paddle/operators/fc_op.cc index ec76d6c659..6e6a09bc3f 100644 --- a/paddle/operators/fc_op.cc +++ b/paddle/operators/fc_op.cc @@ -37,7 +37,7 @@ class FCOp : public NetOp { // mul_out = X[0] * W[0] + ... + X[n-1] * W[n-1] AppendOp( - framework::OpRegistry::CreateOp("mul", {{"X", {x[0]}}, {"W", {w[0]}}}, + framework::OpRegistry::CreateOp("mul", {{"X", {x[0]}}, {"Y", {w[0]}}}, {{"Out", {Output("mul_out")}}}, {})); for (int i = 1; i < n; i++) { @@ -68,6 +68,8 @@ class FCOp : public NetOp { AppendOp(framework::OpRegistry::CreateOp( activation, {{"X", {Output(add_out)}}}, {{"Y", {Output("Y")}}}, {})); CompleteAddOp(false); + + std::cout << DebugString() << std::endl; } }; diff --git a/python/paddle/v2/framework/tests/op_test.py b/python/paddle/v2/framework/tests/op_test.py index 3a6a5dca4c..b524f88551 100644 --- a/python/paddle/v2/framework/tests/op_test.py +++ b/python/paddle/v2/framework/tests/op_test.py @@ -36,8 +36,8 @@ def create_op(scope, op_type, inputs, outputs, attrs=None): var = scope.new_var(out_name) kwargs[out_name].append(out_name) - for attr_name in Operator.get_op_attr_names(op_type): - kwargs[attr_name] = attrs[attr_name] + #for attr_name in Operator.get_op_attr_names(op_type): + # kwargs[attr_name] = attrs[attr_name] return Operator(op_type, **kwargs) @@ -186,14 +186,14 @@ class OpTest(unittest.TestCase): self.assertTrue( np.allclose( actual, expect, atol=1e-05), - "output name: " + out_name + "has diff") + "output name: " + out_name + " has diff") else: actual = np.array(self.scope.find_var(out_name).get_tensor()) expect = self.outputs[out_name] self.assertTrue( np.allclose( actual, expect, atol=1e-05), - "output name: " + out_name + "has diff") + "output name: " + out_name + " has diff") def check_output(self): places = [core.CPUPlace()] diff --git a/python/paddle/v2/framework/tests/test_fc_op.py b/python/paddle/v2/framework/tests/test_fc_op.py index 72d750111c..959bd7e405 100644 --- a/python/paddle/v2/framework/tests/test_fc_op.py +++ b/python/paddle/v2/framework/tests/test_fc_op.py @@ -1,8 +1,6 @@ import unittest import numpy as np from op_test import OpTest -import paddle.v2.framework.core as core -from paddle.v2.framework.op import Operator class TestFCOp(OpTest): @@ -37,8 +35,7 @@ class TestFCOp(OpTest): } def test_check_output(self): - self.check_output(core.CPUPlace()) - self.check_output(core.GPUPlace(0)) + self.check_output() #def test_check_grad(self): # self.check_grad(["X0", "X1", "W0", "W1", "b"], "Y")