@@ -0,0 +1,2396 @@
+import random%0Aimport unittest%0A%0Aimport numpy%0A%0Aimport chainer%0Afrom chainer import cuda%0Afrom chainer import functions%0Afrom chainer import gradient_check%0Afrom chainer import testing%0Afrom chainer.testing import attr%0Afrom chainer.testing import condition%0A%0A%0A@testing.parameterize(*testing.product(%7B%0A    'shape': %5B(3, 2), ()%5D,%0A    'dtype': %5Bnumpy.float16, numpy.float32, numpy.float64%5D,%0A%7D))%0Aclass TestSELU(unittest.TestCase):%0A%0A    def setUp(self):%0A        # Avoid unstability of numeraical grad%0A        self.x = numpy.random.uniform(-1, 1, self.shape).astype(self.dtype)%0A        for i in numpy.ndindex(self.shape):%0A            if -0.01 %3C self.x%5Bi%5D %3C 0.01:%0A                self.x%5Bi%5D = 0.5%0A        self.gy = numpy.random.uniform(-1, 1, self.shape).astype(self.dtype)%0A        self.alpha = random.random()%0A        self.scale = random.random()%0A        self.check_forward_options = %7B%7D%0A        self.check_backward_options = %7B'dtype': numpy.float64%7D%0A        if self.dtype == numpy.float16:%0A            self.check_forward_options = %7B'atol': 5e-4, 'rtol': 5e-3%7D%0A            self.check_backward_options = %7B%0A                'dtype': numpy.float64, 'atol': 5e-4, 'rtol': 5e-3%7D%0A%0A    def check_forward(self, x_data):%0A        x = chainer.Variable(x_data)%0A        y = functions.selu(x, alpha=self.alpha, scale=self.scale)%0A        self.assertEqual(y.data.dtype, self.dtype)%0A%0A        expected = self.x.copy()%0A        for i in numpy.ndindex(self.x.shape):%0A            if self.x%5Bi%5D %3C 0:%0A                expected%5Bi%5D = self.alpha * (numpy.exp(expected%5Bi%5D) - 1)%0A            expected%5Bi%5D *= self.scale%0A%0A        testing.assert_allclose(%0A            expected, y.data, **self.check_forward_options)%0A%0A    @condition.retry(3)%0A    def test_forward_cpu(self):%0A        self.check_forward(self.x)%0A%0A    @attr.gpu%0A    @condition.retry(3)%0A    def test_forward_gpu(self):%0A        self.check_forward(cuda.to_gpu(self.x))%0A%0A    def check_backward(self, x_data, y_grad):%0A        gradient_check.check_backward(%0A            lambda x: functions.selu(x, alpha=self.alpha, scale=self.scale),%0A            x_data, y_grad,%0A            **self.check_backward_options)%0A%0A    @condition.retry(10)%0A    def test_backward_cpu(self):%0A        self.check_backward(self.x, self.gy)%0A%0A    @attr.gpu%0A    @condition.retry(10)%0A    def test_backward_gpu(self):%0A        self.check_backward(cuda.to_gpu(self.x), cuda.to_gpu(self.gy))%0A%0A%0Atesting.run_module(__name__, __file__)%0A

Add tests for SELU