test_sigmoid_op.py 523 字节
Newer Older
Q
qijun 已提交
1 2
import unittest
import numpy as np
3
from op_test import OpTest
Q
qijun 已提交
4 5


6
class TestSigmoidOp(OpTest):
Q
qijun 已提交
7
    def setUp(self):
8 9 10 11
        self.op_type = "sigmoid"
        self.inputs = {
            'X': np.random.uniform(0.1, 1, [11, 17]).astype("float32")
        }
D
dangqingqing 已提交
12
        self.outputs = {'Y': 1 / (1 + np.exp(-self.inputs['X']))}
Q
qijun 已提交
13

14
    def test_check_output(self):
Q
qijun 已提交
15
        self.check_output()
Q
qijun 已提交
16

17 18
    def test_check_grad(self):
        self.check_grad(["X"], "Y", max_relative_error=0.007)
19

20

Q
qijun 已提交
21 22
if __name__ == '__main__':
    unittest.main()