Example #1
0
    def test_layer_neunet_builder_fail_not_enough_layers(self):
        l_nodes = [1]
        layer_types = ["relu"]

        with pytest.raises(NameError):
            LayerNeuNetBuilder().set_weights_and_bias(l_nodes).set_layers(
                layer_types).build()
Example #2
0
    def test_set_weitghts_and_bias(self):
        l_nodes = [1, 2, 3, 4]
        test_layerbuilder = LayerNeuNetBuilder().set_weights_and_bias(l_nodes)

        assert test_layerbuilder.net.weights is not None
        assert test_layerbuilder.net.bias is not None
        assert test_layerbuilder.net.l_nodes is not None
        assert test_layerbuilder.net.layers is not None
Example #3
0
    def _test_layernet(l_nodes=[10, 7, 5, 3],
                       layer_types="relu",
                       cost_type="exponentialcuadratic"):

        if isinstance(layer_types, list):
            layer_types_list = layer_types
        else:
            layer_types_list = [layer_types] * len(l_nodes)

        test_layernet = LayerNeuNetBuilder() \
            .set_layers(layer_types_list) \
            .set_cost(cost_type) \
            .set_weights_and_bias(l_nodes) \
            .build()

        return test_layernet
Example #4
0
    def test_build_success(self):
        l_nodes = [1, 2, 3, 4]
        cost_type = "cuadratic"
        layer_types = ["relu"] * len(l_nodes)

        test_layernet = LayerNeuNetBuilder(). \
            set_weights_and_bias(l_nodes). \
            set_layers(layer_types). \
            set_cost(cost_type). \
            build()

        assert test_layernet.weights is not None
        assert test_layernet.bias is not None
        assert test_layernet.l_nodes is not None
        assert test_layernet.layers is not None
        assert test_layernet.layer_types is not None
        assert test_layernet.cost_layer is not None
Example #5
0
 def test_layernet_constructor_not_defined(self):
     with pytest.raises(NameError):
         LayerNeuNetBuilder().build()
Example #6
0
    def test_set_exponentialcuadratic_cost(self):
        cost_type = "exponentialcuadratic"

        test_layernetbuilder = LayerNeuNetBuilder().set_cost(cost_type)

        assert test_layernetbuilder.net.cost_layer is not None
Example #7
0
    def test_set_layers_success(self):
        layer_types = ["relu", "sigmoid"]
        test_layerbuilder = LayerNeuNetBuilder().set_layers(layer_types)

        assert test_layerbuilder.net.layer_types is not None