def generate_CNN_model(x_shape, class_number, filters, fc_hidden_nodes, learning_rate=0.01, regularization_rate=0.01, metrics=['accuracy']):
    '\n    Generate a convolutional neural network (CNN) model.\n\n    The compiled Keras model is returned.\n\n    Parameters\n    ----------\n    x_shape : tuple\n        Shape of the input dataset: (num_samples, num_timesteps, num_channels)\n    class_number : int\n        Number of classes for classification task\n    filters : list of ints\n        number of filters for each convolutional layer\n    fc_hidden_nodes : int\n        number of hidden nodes for the hidden dense layer\n    learning_rate : float\n        learning rate\n    regularization_rate : float\n        regularization rate\n    metrics : list\n        Metrics to calculate on the validation set.\n        See https://keras.io/metrics/ for possible values.\n\n    Returns\n    -------\n    model : Keras model\n        The compiled Keras model\n    '
    dim_length = x_shape[1]
    dim_channels = x_shape[2]
    outputdim = class_number
    weightinit = 'lecun_uniform'
    model = Sequential()
    model.add(BatchNormalization(input_shape=(dim_length, dim_channels)))
    for filter_number in filters:
        model.add(Convolution1D(filter_number, kernel_size=3, padding='same', kernel_regularizer=l2(regularization_rate), kernel_initializer=weightinit))
        model.add(BatchNormalization())
        model.add(Activation('relu'))
    model.add(Flatten())
    model.add(Dense(units=fc_hidden_nodes, kernel_regularizer=l2(regularization_rate), kernel_initializer=weightinit))
    model.add(Activation('relu'))
    model.add(Dense(units=outputdim, kernel_initializer=weightinit))
    model.add(BatchNormalization())
    model.add(Activation('softmax'))
    loss = 'categorical_crossentropy'
    model.compile(loss=loss, optimizer=Adam(lr=learning_rate), metrics=metrics)
    return model
Generate a convolutional neural network (CNN) model.

The compiled Keras model is returned.

Parameters
----------
x_shape : tuple
    Shape of the input dataset: (num_samples, num_timesteps, num_channels)
class_number : int
    Number of classes for classification task
filters : list of ints
    number of filters for each convolutional layer
fc_hidden_nodes : int
    number of hidden nodes for the hidden dense layer
learning_rate : float
    learning rate
regularization_rate : float
    regularization rate
metrics : list
    Metrics to calculate on the validation set.
    See https://keras.io/metrics/ for possible values.

Returns
-------
model : Keras model
    The compiled Keras model
def generate_CNN_model(x_shape, class_number, filters, fc_hidden_nodes, learning_rate=0.01, regularization_rate=0.01, metrics=['accuracy']):
    '\n    Generate a convolutional neural network (CNN) model.\n\n    The compiled Keras model is returned.\n\n    Parameters\n    ----------\n    x_shape : tuple\n        Shape of the input dataset: (num_samples, num_timesteps, num_channels)\n    class_number : int\n        Number of classes for classification task\n    filters : list of ints\n        number of filters for each convolutional layer\n    fc_hidden_nodes : int\n        number of hidden nodes for the hidden dense layer\n    learning_rate : float\n        learning rate\n    regularization_rate : float\n        regularization rate\n    metrics : list\n        Metrics to calculate on the validation set.\n        See https://keras.io/metrics/ for possible values.\n\n    Returns\n    -------\n    model : Keras model\n        The compiled Keras model\n    '
    dim_length = x_shape[1]
    dim_channels = x_shape[2]
    outputdim = class_number
    weightinit = 'lecun_uniform'
    model = Sequential()
    model.add(BatchNormalization(input_shape=(dim_length, dim_channels)))
    for filter_number in filters:
        model.add(Convolution1D(filter_number, kernel_size=3, padding='same', kernel_regularizer=l2(regularization_rate), kernel_initializer=weightinit))
        model.add(BatchNormalization())
        model.add(Activation('relu'))
    model.add(Flatten())
    model.add(Dense(units=fc_hidden_nodes, kernel_regularizer=l2(regularization_rate), kernel_initializer=weightinit))
    model.add(Activation('relu'))
    model.add(Dense(units=outputdim, kernel_initializer=weightinit))
    model.add(BatchNormalization())
    model.add(Activation('softmax'))
    loss = 'categorical_crossentropy'
    model.compile(loss=loss, optimizer=Adam(lr=learning_rate), metrics=metrics)
    return model