Logo ROOT  
Reference Guide
make_cnn_model.py
Go to the documentation of this file.
1import keras
2from keras.models import Sequential
3from keras.optimizers import Adam
4from keras.layers import Input, Dense, Dropout, Flatten, Conv2D, MaxPooling2D, Reshape, BatchNormalization
5
6model = keras.models.Sequential()
7model.add(Reshape((16, 16, 1), input_shape = (256, )))
8model.add(Conv2D(10, kernel_size = (3, 3), kernel_initializer = 'glorot_normal',activation = 'relu', padding = 'same'))
9model.add(BatchNormalization())
10model.add(Conv2D(10, kernel_size = (3, 3), kernel_initializer = 'glorot_normal',activation = 'relu', padding = 'same'))
11model.add(MaxPooling2D(pool_size = (2, 2), strides = (1,1)))
12model.add(Flatten())
13model.add(Dense(256, activation = 'relu'))
14model.add(Dense(2, activation = 'sigmoid'))
15model.compile(loss = 'binary_crossentropy', optimizer = Adam(lr = 0.001), metrics = ['accuracy'])
16model.save('model_cnn.h5')
17model.summary()