Пример #1
0
 def test_forward_pass_single_samples(self):
     lc = Sigmoid(1, 1)
     for x, t in zip(self.X, self.T):
         t = np.atleast_2d(t)
         x = np.atleast_2d(x)
         out_buf = np.zeros_like(t)
         lc.forward_pass(np.array([]), [x], out_buf)
         assert_allclose(out_buf, t)
Пример #2
0
 def test_forward_pass_single_samples(self):
     lc = Sigmoid(1, 1)
     for x, t in zip(self.X, self.T):
         t = np.atleast_2d(t)
         x = np.atleast_2d(x)
         out_buf = np.zeros_like(t)
         lc.forward_pass(np.array([]), [x], out_buf)
         assert_allclose(out_buf, t)
Пример #3
0
 def test_forward_pass_multi_sample(self):
     lc = LinearCombination(4, 1)
     sig = Sigmoid(1, 1)
     scc = SequentialContainerConnection(4, 1, [lc, sig])
     out_buf = np.zeros(self.T.shape, dtype=self.T.dtype)
     scc.forward_pass(self.theta, [self.X], out_buf)
     assert_allclose(out_buf, self.T)
Пример #4
0
 def test_dimensions(self):
     lc = LinearCombination(5, 7)
     sig = Sigmoid(7, 7)
     scc = SequentialContainerConnection(5, 7, [lc, sig])
     self.assertEqual(scc.input_dim, 5)
     self.assertEqual(scc.output_dim, 7)
     self.assertEqual(scc.get_param_dim(), 5 * 7)
Пример #5
0
 def test_forward_pass_single_samples(self):
     lc = LinearCombination(4, 1)
     sig = Sigmoid(1, 1)
     scc = SequentialContainerConnection(4, 1, [lc, sig])
     for x, t in zip(self.X, self.T):
         t = np.atleast_2d(t)
         x = np.atleast_2d(x)
         out_buf = np.zeros_like(t)
         scc.forward_pass(self.theta, [x], out_buf)
         assert_allclose(out_buf, t)
Пример #6
0
 def test_backprop_multisample_zero_is_zero(self):
     lc = LinearCombination(4, 1)
     sig = Sigmoid(1, 1)
     scc = SequentialContainerConnection(4, 1, [lc, sig])
     in_error_buffers = [np.zeros_like(self.X)]
     scc.backprop(self.theta, [self.X], self.T, np.zeros_like(self.T),
                  in_error_buffers)
     grad = np.zeros_like(self.theta)
     scc.calculate_gradient(self.theta, grad, [self.X], self.T,
                            in_error_buffers, np.zeros_like(self.T))
     assert_allclose(in_error_buffers[0], np.zeros_like(self.X))
     assert_allclose(grad, np.zeros_like(self.theta))
Пример #7
0
 def test_forward_pass_multi_sample(self):
     lc = Sigmoid(1, 1)
     out_buf = np.zeros(self.T.shape, dtype=self.T.dtype)
     lc.forward_pass(np.array([]), [self.X], out_buf)
     assert_allclose(out_buf, self.T)
Пример #8
0
 def test_dimensions(self):
     lc = Sigmoid(5, 5)
     self.assertEqual(lc.input_dim, 5)
     self.assertEqual(lc.output_dim, 5)
     self.assertEqual(lc.get_param_dim(), 0)
Пример #9
0
 def test_backprop_multisample(self):
     lc = LinearCombination(4, 1)
     sig = Sigmoid(1, 1)
     scc = SequentialContainerConnection(4, 1, [lc, sig])
     assert_backprop_correct(scc, self.theta, [self.X],
                             np.ones_like(self.T))
Пример #10
0
 def test_backprop_multisample(self):
     lc = Sigmoid(1, 1)
     assert_backprop_correct(lc, np.array([]), [self.X],
                             np.ones_like(self.T))
Пример #11
0
 def test_forward_pass_multi_sample(self):
     lc = Sigmoid(1, 1)
     out_buf = np.zeros(self.T.shape, dtype=self.T.dtype)
     lc.forward_pass(np.array([]), [self.X], out_buf)
     assert_allclose(out_buf, self.T)
Пример #12
0
 def test_dimensions(self):
     lc = Sigmoid(5, 5)
     self.assertEqual(lc.input_dim, 5)
     self.assertEqual(lc.output_dim, 5)
     self.assertEqual(lc.get_param_dim(), 0)