Guest User

Untitled

a guest
Aug 15th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. from keras.models import Sequential
  2. from keras.layers import Dense, MaxPooling2D, Conv2D, Flatten
  3.  
  4. def build_keras_model():
  5. # this is the same configuration that Francois Chollet used in his cats vs dogs problem
  6. model = Sequential()
  7. # CNN layers
  8. model.add(Conv2D(filters=64, activation='relu', kernel_size=ksize,
  9. strides=strides, padding='same',
  10. input_shape=(image_height, image_width, num_channels)))
  11. model.add(MaxPooling2D(pool_size=psize))
  12. model.add(Conv2D(filters=128, activation='relu', kernel_size=ksize,
  13. strides=strides, padding='same'))
  14. model.add(MaxPooling2D(pool_size=psize))
  15. model.add(Conv2D(filters=128, activation='relu', kernel_size=ksize,
  16. strides=strides, padding='same'))
  17. model.add(MaxPooling2D(pool_size=psize))
  18. # Flatten
  19. model.add(Flatten())
  20. # Dense (fully connected) layers
  21. model.add(Dense(512, activation='relu'))
  22. # output layer with softmax
  23. model.add(Dense(10, activation='softmax'))
  24. # compile with categorical_crossentropy loss function & adam optimizer
  25. #adam = Adam(lr=0.001)
  26. model.compile(optimizer='rmsprop', loss='categorical_crossentropy',
  27. metrics=['accuracy'])
  28. return model
  29.  
  30. # create the model & show structure
  31. kr_base_model = build_keras_model()
  32. print(kr_base_model.summary())
Add Comment
Please, Sign In to add comment