示例#1
0
 def test_zero(self):
     x = np.zeros((2, 3))
     s1 = hoyer_sparseness(x)
     self.assertEqual(s1, 1.)
示例#2
0
 def test_is_0_on_flat(self):
     x = np.ones((1, 4))
     self.assertAlmostEqual(hoyer_sparseness(x), 0.)
示例#3
0
 def test_is_1_on_spike(self):
     x = np.zeros((1, 4))
     x[0, 2] = 10.
     self.assertEqual(hoyer_sparseness(x), 1.)
示例#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))
示例#5
0
 def test_axis(self):
     x = np.array([[1, 1],
                   [0, 0]])
     s1 = hoyer_sparseness(x, axis=0)
     self.assertEqual(s1, 1.)
示例#6
0
 def test_zero(self):
     x = np.zeros((2, 3))
     s1 = hoyer_sparseness(x)
     self.assertEqual(s1, 1.)
示例#7
0
 def test_is_1_on_spike(self):
     x = np.zeros((1, 4))
     x[0, 2] = 10.
     self.assertEqual(hoyer_sparseness(x), 1.)
示例#8
0
 def test_is_0_on_flat(self):
     x = np.ones((1, 4))
     self.assertAlmostEqual(hoyer_sparseness(x), 0.)
示例#9
0
 def test_axis(self):
     x = np.array([[1, 1], [0, 0]])
     s1 = hoyer_sparseness(x, axis=0)
     self.assertEqual(s1, 1.)
示例#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))