def make_model(dense_layer_sizes, nb_filters, nb_conv, nb_pool):
 model = Sequential()
 model.add(Convolution2D(nb_filters, nb_conv, nb_conv, border_mode='valid', input_shape=(1, img_rows, img_cols)))
 model.add(Activation('relu'))
 model.add(Convolution2D(nb_filters, nb_conv, nb_conv))
 model.add(Activation('relu'))
 model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
 model.add(Dropout(0.25))
 model.add(Flatten())
 for layer_size in dense_layer_sizes:
  model.add(Dense(layer_size))
 model.add(Activation('relu'))
 model.add(Dropout(0.5))
 model.add(Dense(nb_classes))
 model.add(Activation('softmax'))
 model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])
 return model

def make_model ( dense_layer_sizes , nb_filters , nb_conv , nb_pool ) : model = Sequential ( ) model . add ( Convolution2D ( nb_filters , nb_conv , nb_conv , border_mode = 'valid' , input_shape = ( 1 , img_rows , img_cols ) ) ) model . add ( Activation ( 'relu' ) ) model . add ( Convolution2D ( nb_filters , nb_conv , nb_conv ) ) model . add ( Activation ( 'relu' ) ) model . add ( MaxPooling2D ( pool_size = ( nb_pool , nb_pool ) ) ) model . add ( Dropout ( 0.25 ) ) model . add ( Flatten ( ) ) for layer_size in dense_layer_sizes : model . add ( Dense ( layer_size ) ) model . add ( Activation ( 'relu' ) ) model . add ( Dropout ( 0.5 ) ) model . add ( Dense ( nb_classes ) ) model . add ( Activation ( 'softmax' ) ) model . compile ( loss = 'categorical_crossentropy' , optimizer = 'adadelta' , metrics = [ 'accuracy' ] ) return model
creates model comprised of 2 convolutional layers followed by dense layers dense_layer_sizes: list of layer sizes .