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