add shifted softplus for stablity
@@ -18,6 +18,13 @@ def test_forward_cpu():
numpy.allclose(output.array, expect_output)
+def test_forward_zero_cpu():
+ x = numpy.zeros((2, 3), dtype=numpy.float32)
+ output = shifted_softplus(x)
+ expect_output = numpy.zeros((2, 3), dtype=numpy.float32)
+ numpy.allclose(output.array, expect_output)
+
+
@pytest.mark.gpu
def test_forward_gpu():
x = cuda.to_gpu(numpy.array([[1, 2, 3], [6, 5, 4]], dtype=numpy.float32))
@@ -28,5 +35,13 @@ def test_forward_gpu():
numpy.allclose(cuda.to_cpu(output.array), expect_output)
+@pytest.mark.gpu
+def test_forward_zero_gpu():
+ x = cuda.to_gpu(numpy.zeros((2, 3), dtype=numpy.float32))
+ output = shifted_softplus(x)
+ expect_output = numpy.zeros((2, 3), dtype=numpy.float32)
+ numpy.allclose(cuda.to_cpu(output.array), expect_output)
+
+
if __name__ == '__main__':
pytest.main([__file__, '-v', '-s'])
