test_split_op.py 635 字节
Newer Older
Y
Yancey 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import unittest
import numpy as np
from op_test import OpTest


class TestSplitOp(OpTest):
    def setUp(self):
        self.op_type = "split"
        axis = 0
        num = 2
        x = np.random.random((4, 2)).astype('float32')
        out = np.split(x, num, axis)
        self.inputs = {'X': x}
        self.attrs = {'axis': axis, 'num': num}
        self.outputs = {'Out': [('out%d' % i, out[i]) \
            for i in xrange(len(out))]}

    def test_check_output(self):
        self.check_output()

    def test_check_grad(self):
        self.check_grad(['X'], ['out0', 'out1'])


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