test_mean_op.py 649 字节
Newer Older
L
liaogang 已提交
1 2
import unittest
from op_test_util import OpTestMeta
3
from gradient_checker import GradientChecker, create_op
L
liaogang 已提交
4 5 6 7 8 9 10 11
import numpy as np


class TestMeanOp(unittest.TestCase):
    __metaclass__ = OpTestMeta

    def setUp(self):
        self.type = "mean"
D
dangqingqing 已提交
12 13
        self.inputs = {'X': np.random.random((32, 784)).astype("float32")}
        self.outputs = {'Out': np.mean(self.inputs['X'])}
L
liaogang 已提交
14 15


16 17 18 19 20 21 22
class MeanGradOpTest(GradientChecker):
    def test_normal(self):
        op = create_op("mean")
        inputs = {"X": np.random.random((10, 10)).astype("float32")}
        self.check_grad(op, inputs, set("X"), "Out")


L
liaogang 已提交
23 24
if __name__ == '__main__':
    unittest.main()