dcase_util.keras.create_sequential_model

dcase_util.keras.create_sequential_model(model_parameter_list, input_shape=None, output_shape=None, constants=None, return_functional=False)[source]

Create sequential Keras model

Example parameters:

model_parameter_list = [
    {
        'class_name': 'Dense',
        'config': {
            'units': 'CONSTANT_B',
            'kernel_initializer': 'uniform',
            'activation': 'relu'
        }
    },
    {
        'class_name': 'Dropout',
        'config': {
            'rate': 0.2
        }
    },
    {
        'class_name': 'Dense',
        'config': {
            'units': 'CONSTANT_A' * 2,
            'kernel_initializer': 'uniform',
            'activation': 'relu'
        }
    },
    {
        'class_name': 'Dropout',
        'config': {
            'rate': 0.2
        }
    },
    {
        'class_name': 'Dense',
        'config': {
            'units': 'CLASS_COUNT',
            'kernel_initializer': 'uniform',
            'activation': 'softmax'
        }
    }
]
constants = {
    'CONSTANT_A': 50,
    'CONSTANT_B': 100
}
Parameters
model_parameter_listdict or DictContainer

Model parameters

input_shapeint

Size of the input layer Default value None

output_shapeint

Size of the output layer Default value None

constantsdict or DictContainer

Constants used in the model_parameter definitions. Default value None

return_functionalbool

Convert sequential model into function model. Default value False

Returns
Keras model