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


Q
qijun 已提交
6
class TestRelu(OpTest):
Q
qijun 已提交
7
    def setUp(self):
Q
qijun 已提交
8
        self.op_type = "relu"
Q
qijun 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22
        self.inputs = {
            'X': np.random.uniform(-1, 1, [11, 17]).astype("float32")
        }
        self.outputs = {'Y': np.maximum(self.inputs['X'], 0)}

    def test_check_output(self):
        self.check_output()

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


if __name__ == '__main__':
    unittest.main()