Ejemplo n.º 1
0
    def test_invalid_pad(self, DummyInputLayer):
        from lasagne.layers.conv import Conv1DLayer
        input_layer = DummyInputLayer((1, 2, 3))
        with pytest.raises(TypeError) as exc:
            layer = Conv1DLayer(input_layer, num_filters=16, filter_size=(3,),
                                pad='_nonexistent_mode')
        assert "iterable of int" in exc.value.args[0]

        with pytest.raises(NotImplementedError) as exc:
            layer = Conv1DLayer(input_layer, num_filters=16, filter_size=(4,),
                                pad='same')
        assert "requires odd filter size" in exc.value.args[0]
Ejemplo n.º 2
0
 def test_init_none_nonlinearity_bias(self, DummyInputLayer):
     from lasagne.layers.conv import Conv1DLayer
     input_layer = DummyInputLayer((1, 2, 3))
     layer = Conv1DLayer(input_layer, num_filters=16, filter_size=(3,),
                         nonlinearity=None, b=None)
     assert layer.nonlinearity == lasagne.nonlinearities.identity
     assert layer.b is None
Ejemplo n.º 3
0
 def test_invalid_border_mode(self, DummyInputLayer):
     from lasagne.layers.conv import Conv1DLayer
     input_layer = DummyInputLayer((1, 2, 3))
     with pytest.raises(RuntimeError) as exc:
         layer = Conv1DLayer(input_layer,
                             num_filters=16,
                             filter_size=(3, ),
                             border_mode='_nonexistent_mode')
     assert "Invalid border mode" in exc.value.args[0]
Ejemplo n.º 4
0
    def test_defaults(self, DummyInputLayer, input, kernel, output, kwargs):
        b, c, w = input.shape.eval()
        input_layer = DummyInputLayer((b, c, w))
        try:
            from lasagne.layers.conv import Conv1DLayer
            layer = Conv1DLayer(input_layer,
                                num_filters=kernel.shape[0],
                                filter_size=kernel.shape[2],
                                W=kernel,
                                **kwargs)
            actual = layer.get_output_for(input).eval()
            assert actual.shape == output.shape
            assert actual.shape == layer.output_shape
            assert np.allclose(actual, output)

        except NotImplementedError:
            pass