Exemple #1
0
 def test_weighs_structure(self):
     ann = NeuralNetwork([5, 3], alpha=1e-5)
     ann.set_data_(self.X, self.y)
     coefs = ann.unflatten_coefs(ann.init_weights_())
     shapes = np.array([coef.shape for coef in coefs])
     np.testing.assert_array_equal(shapes, np.array([[5, 5], [6, 3], [4,
                                                                      3]]))
Exemple #2
0
 def test_gradient_computation(self):
     ann = NeuralNetwork([2, 2], alpha=1e-5)
     ann.set_data_(self.X, self.y)
     coefs = ann.init_weights_()
     g1 = ann.grad_approx(coefs, e=1e-5)
     g2 = ann.grad(coefs)
     np.testing.assert_array_almost_equal(g1, g2, decimal=10)
Exemple #3
0
 def test_set_data(self):
     ann = NeuralNetwork([5, 3], alpha=1e-5)
     ann.set_data_(self.X, self.y)
     coefs = ann.init_weights_()
     self.assertEqual(len(coefs), 55)