Beispiel #1
0
    def test_raises_exception_for_erroneous_index(self):
        layer = Layer(size=3,
                      prev_size=2,
                      activation=activation_functions.Sigmoid)

        self.assertRaises(IndexError,
                          lambda: layer.set_bias(row=3, new_value=2))
        self.assertRaises(IndexError,
                          lambda: layer.set_bias(row=30, new_value=2))
Beispiel #2
0
    def test_set_bias(self):
        layer = Layer(size=3,
                      prev_size=2,
                      activation=activation_functions.Sigmoid)
        layer.set_bias(row=0, new_value=2)
        layer.set_bias(row=1, new_value=-0.5)

        expected_b = np.array([2, -0.5, 0], float)

        self.assertEqual(layer.biases().tolist(), expected_b.tolist())