提交 4223ff8c 编写于 作者: L Liu Yiqun

Correct the key name of "mul" op in FCOp, and add some annotations for debug.

上级 70e60d73
......@@ -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;
}
};
......
......@@ -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()]
......
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")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册