Beispiel #1
0
    def test_with_single_hidden_layer(self):
        layer = Layer(size=3,
                      prev_size=2,
                      activation=activation_functions.Sigmoid)
        weights = [[0, 10], [1, 1], [-1, 0.5]]
        layer.set_weights(weights=np.array(weights, float))

        self.assertEqual(layer.weights().tolist(),
                         [[0, 10], [1, 1], [-1, 0.5]])
Beispiel #2
0
    def test_raises_exception_for_array_with_wrong_dimension(self):
        layer = Layer(size=5,
                      prev_size=2,
                      activation=activation_functions.Sigmoid)

        self.assertRaises(Layer.InvalidMatrixDimensions,
                          lambda: layer.set_weights(weights=np.zeros((2, 2))))

        self.assertRaises(Layer.InvalidMatrixDimensions,
                          lambda: layer.set_weights(weights=np.zeros((4, 3))))