Ejemplo n.º 1
0
 def test_zero(self):
     x = np.zeros((2, 3))
     s1 = hoyer_sparseness(x)
     self.assertEqual(s1, 1.)
Ejemplo n.º 2
0
 def test_is_0_on_flat(self):
     x = np.ones((1, 4))
     self.assertAlmostEqual(hoyer_sparseness(x), 0.)
Ejemplo n.º 3
0
 def test_is_1_on_spike(self):
     x = np.zeros((1, 4))
     x[0, 2] = 10.
     self.assertEqual(hoyer_sparseness(x), 1.)
Ejemplo n.º 4
0
 def test_is_in_0_1(self):
     x = np.random.random((5, 7))
     s = hoyer_sparseness(x)
     assert(np.all(0 <= s <= 1))
Ejemplo n.º 5
0
 def test_axis(self):
     x = np.array([[1, 1],
                   [0, 0]])
     s1 = hoyer_sparseness(x, axis=0)
     self.assertEqual(s1, 1.)
Ejemplo n.º 6
0
 def test_zero(self):
     x = np.zeros((2, 3))
     s1 = hoyer_sparseness(x)
     self.assertEqual(s1, 1.)
Ejemplo n.º 7
0
 def test_is_1_on_spike(self):
     x = np.zeros((1, 4))
     x[0, 2] = 10.
     self.assertEqual(hoyer_sparseness(x), 1.)
Ejemplo n.º 8
0
 def test_is_0_on_flat(self):
     x = np.ones((1, 4))
     self.assertAlmostEqual(hoyer_sparseness(x), 0.)
Ejemplo n.º 9
0
 def test_axis(self):
     x = np.array([[1, 1], [0, 0]])
     s1 = hoyer_sparseness(x, axis=0)
     self.assertEqual(s1, 1.)
Ejemplo n.º 10
0
 def test_is_in_0_1(self):
     x = np.random.random((5, 7))
     s = hoyer_sparseness(x)
     assert (np.all(0 <= s <= 1))