#NEWLINE# def make_model( dense_layer_sizes , nb_filters , nb_conv , nb_pool ) : #NEWLINE# #INDENT# 'Creates model comprised of 2 convolutional layers followed by dense layers\n\n    dense_layer_sizes: List of layer sizes. This list has one number for each layer\n    nb_filters: Number of convolutional filters in each convolutional layer\n    nb_conv: Convolutional kernel size\n    nb_pool: Size of pooling area for max pooling\n    ' #NEWLINE# model = Sequential ( ) #NEWLINE# model . add ( Convolution2D ( nb_filters , nb_conv , model , border_mode = 'valid' , input_shape = ( 1 , img_rows , img_cols ) ) ) #NEWLINE# model . add ( Activation ( 'relu' ) ) #NEWLINE# model . add ( Convolution2D ( nb_filters , nb_conv , nb_conv ) ) #NEWLINE# model . add ( Activation ( 'relu' ) ) #NEWLINE# model . add ( MaxPooling2D ( pool_size = ( nb_pool , nb_pool ) ) ) #NEWLINE# model . add ( Dropout ( 0.25 ) ) #NEWLINE# model . add ( Flatten ( ) ) #NEWLINE# for layer_size in dense_layer_sizes : #NEWLINE# #INDENT# model . add ( Dense ( layer_size ) ) #NEWLINE# #UNINDENT# model . add ( Activation ( 'relu' ) ) #NEWLINE# model . add ( Dropout ( 0.5 ) ) #NEWLINE# model . add ( Dense ( nb_classes ) ) #NEWLINE# model . add ( Activation ( 'softmax' ) ) #NEWLINE# model . compile ( loss = 'categorical_crossentropy' , optimizer = 'adadelta' , metrics = [ 'accuracy' ] ) #NEWLINE# return model