Beispiel #1
0
    def test_ResNet_hyperparameters(self):
        """ Network depth from range [4,4] should be 4.
        Maximum kernal size from range [10, 10] should be 10.
        Minimum filter number from range [16, 16] should be 16.  """
        custom_settings = get_default()
        kwargs = {
            'resnet_min_network_depth': 4,
            'resnet_max_network_depth': 4,
            'resnet_min_max_kernel_size': 10,
            'resnet_max_max_kernel_size': 10,
            'resnet_min_filters_number': 16,
            'resnet_max_filters_number': 16
        }
        # Replace default parameters with input
        for key, value in kwargs.items():
            if key in custom_settings:
                custom_settings[key] = value

        model_type = ResNet(None, None, **custom_settings)
        hyperparams = model_type.generate_hyperparameters()

        assert hyperparams.get('network_depth') == 4, 'Wrong network depth'
        assert hyperparams.get('max_kernel_size') == 10, 'Wrong kernel'
        assert hyperparams.get(
            'min_filters_number') == 16, 'Wrong filter number'
Beispiel #2
0
    def test_InceptionTime_hyperparameters(self):
        """ Network depth from range [5,5] should be 5.
        Maximum kernal size from range [12, 12] should be 12.
        Minimum filter number from range [32, 32] should be 32.  """
        custom_settings = get_default()
        x_shape = (None, 20, 3)
        kwargs = {
            'IT_min_network_depth': 5,
            'IT_max_network_depth': 5,
            'IT_min_max_kernel_size': 10,
            'IT_max_max_kernel_size': 10,
            'IT_min_filters_number': 32,
            'IT_max_filters_number': 32
        }
        # Replace default parameters with input
        for key, value in kwargs.items():
            if key in custom_settings:
                custom_settings[key] = value

        model_type = InceptionTime(x_shape, None, **custom_settings)
        hyperparams = model_type.generate_hyperparameters()

        assert hyperparams.get('network_depth') == 5, 'Wrong network depth'
        assert hyperparams.get('max_kernel_size') == 10, 'Wrong kernel'
        assert hyperparams.get('filters_number') == 32, 'Wrong filter number'
Beispiel #3
0
    def test_CNN_hyperparameters_fcnodes(self):
        """ Number of fc nodes from range [123, 123] should be 123. """
        custom_settings = get_default()
        kwargs = {'cnn_min_fc_nodes': 123, 'cnn_max_fc_nodes': 123}
        # Replace default parameters with input
        for key, value in kwargs.items():
            if key in custom_settings:
                custom_settings[key] = value

        model_type = CNN(None, None, **custom_settings)
        hyperparams = model_type.generate_hyperparameters()

        assert hyperparams.get('fc_hidden_nodes') == 123
Beispiel #4
0
    def test_CNN_hyperparameters_nrlayers(self):
        """ Number of Conv layers from range [4, 4] should be 4. """
        custom_settings = get_default()
        kwargs = {'cnn_min_layers': 4, 'cnn_max_layers': 4}
        # Replace default parameters with input
        for key, value in kwargs.items():
            if key in custom_settings:
                custom_settings[key] = value

        model_type = CNN(None, None, **custom_settings)
        hyperparams = model_type.generate_hyperparameters()

        assert len(hyperparams.get('filters')) == 4