Created
May 5, 2018 16:36
-
-
Save CVxTz/3d76335e58c24d991b9912f9c0cc423f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_model(n_classes=1): | |
| base_model = ResNet50(weights='imagenet', include_top=False) | |
| #for layer in base_model.layers: | |
| # layer.trainable = False | |
| x = base_model.output | |
| x = GlobalMaxPooling2D()(x) | |
| x = Dropout(0.5)(x) | |
| x = Dense(100, activation="relu")(x) | |
| x = Dropout(0.5)(x) | |
| if n_classes == 1: | |
| x = Dense(n_classes, activation="sigmoid")(x) | |
| else: | |
| x = Dense(n_classes, activation="softmax")(x) | |
| base_model = Model(base_model.input, x, name="base_model") | |
| if n_classes == 1: | |
| base_model.compile(loss="binary_crossentropy", metrics=['acc'], optimizer="adam") | |
| else: | |
| base_model.compile(loss="sparse_categorical_crossentropy", metrics=['acc'], optimizer="adam") | |
| return base_model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment