test_split_op.py 644 字节
Newer Older
Y
Yancey 已提交
1 2 3 4 5 6 7 8 9
import unittest
import numpy as np
from op_test import OpTest


class TestSplitOp(OpTest):
    def setUp(self):
        self.op_type = "split"
        axis = 0
10 11
        x = np.random.random((4, 2, 5)).astype('float32')
        out = np.split(x, [1, 3], axis)
Y
Yancey 已提交
12
        self.inputs = {'X': x}
13
        self.attrs = {'axis': axis, 'sections': [1, 2, 1]}
Y
Yancey 已提交
14 15 16 17 18 19 20
        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):
21
        self.check_grad(['X'], ['out0', 'out1', 'out2'])
Y
Yancey 已提交
22 23 24 25


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