def generate_models(x_shape, number_of_classes, number_of_models=5, metrics=['accuracy'], model_type=None, cnn_min_layers=5, cnn_max_layers=10, cnn_min_filters=25, cnn_max_filters=100, cnn_min_fc_nodes=500, cnn_max_fc_nodes=1000, deepconvlstm_min_conv_layers=3, deepconvlstm_max_conv_layers=7, deepconvlstm_min_conv_filters=25, deepconvlstm_max_conv_filters=100, deepconvlstm_min_lstm_layers=1, deepconvlstm_max_lstm_layers=3, deepconvlstm_min_lstm_dims=100, deepconvlstm_max_lstm_dims=500, low_lr=1, high_lr=4, low_reg=1, high_reg=3):
    "\n    Generate one or multiple untrained Keras models with random hyperparameters.\n\n    Parameters\n    ----------\n    x_shape : tuple\n        Shape of the input dataset: (num_samples, num_timesteps, num_channels)\n    number_of_classes : int\n        Number of classes for classification task\n    number_of_models : int\n        Number of models to generate\n    metrics : list\n        Metrics to calculate on the validation set.\n        See https://keras.io/metrics/ for possible values.\n    model_type : str, optional\n        Type of model to build: 'CNN' or 'DeepConvLSTM'.\n        Default option None generates both models.\n    cnn_min_layers : int\n        minimum of Conv layers in CNN model\n    cnn_max_layers : int\n        maximum of Conv layers in CNN model\n    cnn_min_filters : int\n        minimum number of filters per Conv layer in CNN model\n    cnn_max_filters : int\n        maximum number of filters per Conv layer in CNN model\n    cnn_min_fc_nodes : int\n        minimum number of hidden nodes per Dense layer in CNN model\n    cnn_max_fc_nodes : int\n        maximum number of hidden nodes per Dense layer in CNN model\n    deepconvlstm_min_conv_layers : int\n        minimum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_max_conv_layers : int\n        maximum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_min_conv_filters : int\n        minimum number of filters per Conv layer in DeepConvLSTM model\n    deepconvlstm_max_conv_filters : int\n        maximum number of filters per Conv layer in DeepConvLSTM model\n    deepconvlstm_min_lstm_layers : int\n        minimum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_max_lstm_layers : int\n        maximum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_min_lstm_dims : int\n        minimum number of hidden nodes per LSTM layer in DeepConvLSTM model\n    deepconvlstm_max_lstm_dims : int\n        maximum number of hidden nodes per LSTM layer in DeepConvLSTM model\n    low_lr : float\n        minimum of log range for learning rate: learning rate is sampled\n        between `10**(-low_reg)` and `10**(-high_reg)`\n    high_lr : float\n        maximum  of log range for learning rate: learning rate is sampled\n        between `10**(-low_reg)` and `10**(-high_reg)`\n    low_reg : float\n        minimum  of log range for regularization rate: regularization rate is\n        sampled between `10**(-low_reg)` and `10**(-high_reg)`\n    high_reg : float\n        maximum  of log range for regularization rate: regularization rate is\n        sampled between `10**(-low_reg)` and `10**(-high_reg)`\n\n    Returns\n    -------\n    models : list\n        List of compiled models\n    "
    models = []
    for _ in range(0, number_of_models):
        if (model_type is None):
            current_model_type = ('CNN' if (np.random.random() < 0.5) else 'DeepConvLSTM')
        else:
            current_model_type = model_type
        generate_model = None
        if (current_model_type == 'CNN'):
            generate_model = generate_CNN_model
            hyperparameters = generate_CNN_hyperparameter_set(min_layers=cnn_min_layers, max_layers=cnn_max_layers, min_filters=cnn_min_filters, max_filters=cnn_max_filters, min_fc_nodes=cnn_min_fc_nodes, max_fc_nodes=cnn_max_fc_nodes, low_lr=low_lr, high_lr=high_lr, low_reg=low_reg, high_reg=high_reg)
        if (current_model_type == 'DeepConvLSTM'):
            generate_model = generate_DeepConvLSTM_model
            hyperparameters = generate_DeepConvLSTM_hyperparameter_set(min_conv_layers=deepconvlstm_min_conv_layers, max_conv_layers=deepconvlstm_max_conv_layers, min_conv_filters=deepconvlstm_min_conv_filters, max_conv_filters=deepconvlstm_max_conv_filters, min_lstm_layers=deepconvlstm_min_lstm_layers, max_lstm_layers=deepconvlstm_max_lstm_layers, min_lstm_dims=deepconvlstm_min_lstm_dims, max_lstm_dims=deepconvlstm_max_lstm_dims, low_lr=low_lr, high_lr=high_lr, low_reg=low_reg, high_reg=high_reg)
        models.append((generate_model(x_shape, number_of_classes, metrics=metrics, **hyperparameters), hyperparameters, current_model_type))
    return models
Generate one or multiple untrained Keras models with random hyperparameters.

Parameters
----------
x_shape : tuple
    Shape of the input dataset: (num_samples, num_timesteps, num_channels)
number_of_classes : int
    Number of classes for classification task
number_of_models : int
    Number of models to generate
metrics : list
    Metrics to calculate on the validation set.
    See https://keras.io/metrics/ for possible values.
model_type : str, optional
    Type of model to build: 'CNN' or 'DeepConvLSTM'.
    Default option None generates both models.
cnn_min_layers : int
    minimum of Conv layers in CNN model
cnn_max_layers : int
    maximum of Conv layers in CNN model
cnn_min_filters : int
    minimum number of filters per Conv layer in CNN model
cnn_max_filters : int
    maximum number of filters per Conv layer in CNN model
cnn_min_fc_nodes : int
    minimum number of hidden nodes per Dense layer in CNN model
cnn_max_fc_nodes : int
    maximum number of hidden nodes per Dense layer in CNN model
deepconvlstm_min_conv_layers : int
    minimum number of Conv layers in DeepConvLSTM model
deepconvlstm_max_conv_layers : int
    maximum number of Conv layers in DeepConvLSTM model
deepconvlstm_min_conv_filters : int
    minimum number of filters per Conv layer in DeepConvLSTM model
deepconvlstm_max_conv_filters : int
    maximum number of filters per Conv layer in DeepConvLSTM model
deepconvlstm_min_lstm_layers : int
    minimum number of Conv layers in DeepConvLSTM model
deepconvlstm_max_lstm_layers : int
    maximum number of Conv layers in DeepConvLSTM model
deepconvlstm_min_lstm_dims : int
    minimum number of hidden nodes per LSTM layer in DeepConvLSTM model
deepconvlstm_max_lstm_dims : int
    maximum number of hidden nodes per LSTM layer in DeepConvLSTM model
low_lr : float
    minimum of log range for learning rate: learning rate is sampled
    between `10**(-low_reg)` and `10**(-high_reg)`
high_lr : float
    maximum  of log range for learning rate: learning rate is sampled
    between `10**(-low_reg)` and `10**(-high_reg)`
low_reg : float
    minimum  of log range for regularization rate: regularization rate is
    sampled between `10**(-low_reg)` and `10**(-high_reg)`
high_reg : float
    maximum  of log range for regularization rate: regularization rate is
    sampled between `10**(-low_reg)` and `10**(-high_reg)`

Returns
-------
models : list
    List of compiled models
def generate_models(x_shape, number_of_classes, number_of_models=5, metrics=['accuracy'], model_type=None, cnn_min_layers=5, cnn_max_layers=10, cnn_min_filters=25, cnn_max_filters=100, cnn_min_fc_nodes=500, cnn_max_fc_nodes=1000, deepconvlstm_min_conv_layers=3, deepconvlstm_max_conv_layers=7, deepconvlstm_min_conv_filters=25, deepconvlstm_max_conv_filters=100, deepconvlstm_min_lstm_layers=1, deepconvlstm_max_lstm_layers=3, deepconvlstm_min_lstm_dims=100, deepconvlstm_max_lstm_dims=500, low_lr=1, high_lr=4, low_reg=1, high_reg=3):
    "\n    Generate one or multiple untrained Keras models with random hyperparameters.\n\n    Parameters\n    ----------\n    x_shape : tuple\n        Shape of the input dataset: (num_samples, num_timesteps, num_channels)\n    number_of_classes : int\n        Number of classes for classification task\n    number_of_models : int\n        Number of models to generate\n    metrics : list\n        Metrics to calculate on the validation set.\n        See https://keras.io/metrics/ for possible values.\n    model_type : str, optional\n        Type of model to build: 'CNN' or 'DeepConvLSTM'.\n        Default option None generates both models.\n    cnn_min_layers : int\n        minimum of Conv layers in CNN model\n    cnn_max_layers : int\n        maximum of Conv layers in CNN model\n    cnn_min_filters : int\n        minimum number of filters per Conv layer in CNN model\n    cnn_max_filters : int\n        maximum number of filters per Conv layer in CNN model\n    cnn_min_fc_nodes : int\n        minimum number of hidden nodes per Dense layer in CNN model\n    cnn_max_fc_nodes : int\n        maximum number of hidden nodes per Dense layer in CNN model\n    deepconvlstm_min_conv_layers : int\n        minimum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_max_conv_layers : int\n        maximum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_min_conv_filters : int\n        minimum number of filters per Conv layer in DeepConvLSTM model\n    deepconvlstm_max_conv_filters : int\n        maximum number of filters per Conv layer in DeepConvLSTM model\n    deepconvlstm_min_lstm_layers : int\n        minimum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_max_lstm_layers : int\n        maximum number of Conv layers in DeepConvLSTM model\n    deepconvlstm_min_lstm_dims : int\n        minimum number of hidden nodes per LSTM layer in DeepConvLSTM model\n    deepconvlstm_max_lstm_dims : int\n        maximum number of hidden nodes per LSTM layer in DeepConvLSTM model\n    low_lr : float\n        minimum of log range for learning rate: learning rate is sampled\n        between `10**(-low_reg)` and `10**(-high_reg)`\n    high_lr : float\n        maximum  of log range for learning rate: learning rate is sampled\n        between `10**(-low_reg)` and `10**(-high_reg)`\n    low_reg : float\n        minimum  of log range for regularization rate: regularization rate is\n        sampled between `10**(-low_reg)` and `10**(-high_reg)`\n    high_reg : float\n        maximum  of log range for regularization rate: regularization rate is\n        sampled between `10**(-low_reg)` and `10**(-high_reg)`\n\n    Returns\n    -------\n    models : list\n        List of compiled models\n    "
    models = []
    for _ in range(0, number_of_models):
        if (model_type is None):
            current_model_type = ('CNN' if (np.random.random() < 0.5) else 'DeepConvLSTM')
        else:
            current_model_type = model_type
        generate_model = None
        if (current_model_type == 'CNN'):
            generate_model = generate_CNN_model
            hyperparameters = generate_CNN_hyperparameter_set(min_layers=cnn_min_layers, max_layers=cnn_max_layers, min_filters=cnn_min_filters, max_filters=cnn_max_filters, min_fc_nodes=cnn_min_fc_nodes, max_fc_nodes=cnn_max_fc_nodes, low_lr=low_lr, high_lr=high_lr, low_reg=low_reg, high_reg=high_reg)
        if (current_model_type == 'DeepConvLSTM'):
            generate_model = generate_DeepConvLSTM_model
            hyperparameters = generate_DeepConvLSTM_hyperparameter_set(min_conv_layers=deepconvlstm_min_conv_layers, max_conv_layers=deepconvlstm_max_conv_layers, min_conv_filters=deepconvlstm_min_conv_filters, max_conv_filters=deepconvlstm_max_conv_filters, min_lstm_layers=deepconvlstm_min_lstm_layers, max_lstm_layers=deepconvlstm_max_lstm_layers, min_lstm_dims=deepconvlstm_min_lstm_dims, max_lstm_dims=deepconvlstm_max_lstm_dims, low_lr=low_lr, high_lr=high_lr, low_reg=low_reg, high_reg=high_reg)
        models.append((generate_model(x_shape, number_of_classes, metrics=metrics, **hyperparameters), hyperparameters, current_model_type))
    return models