comparison tests/test_sigmoid.py @ 42:38aa9098bf2d

derivative of sigmoid
author Jeff Hammel <k0scist@gmail.com>
date Mon, 04 Sep 2017 14:34:00 -0700
parents d6d2ecb33c95
children
comparison
equal deleted inserted replaced
41:8c1648921827 42:38aa9098bf2d
4 test sigmoid related functionality 4 test sigmoid related functionality
5 """ 5 """
6 6
7 import os 7 import os
8 import unittest 8 import unittest
9 from tvii.sigmoid import sigmoid 9 from tvii.sigmoid import sigmoid, sigmoidprime
10 10
11 11
12 class TestSigmoid(unittest.TestCase): 12 class TestSigmoid(unittest.TestCase):
13 13
14 def test_basic(self): 14 def test_basic(self):
17 answer = sigmoid([0,2]) 17 answer = sigmoid([0,2])
18 assert len(answer) == 2 18 assert len(answer) == 2
19 assert answer[0] == 0.5 19 assert answer[0] == 0.5
20 assert abs(answer[1] - 0.88079708) < 1e-6 20 assert abs(answer[1] - 0.88079708) < 1e-6
21 21
22 def test_derivative(self):
23
24 self.assertAlmostEqual(sigmoidprime(0), 0.25)
25
22 if __name__ == '__main__': 26 if __name__ == '__main__':
23 unittest.main() 27 unittest.main()