Created
February 20, 2021 16:37
-
-
Save obeshor/312d5a927b74d044c2dc867bfb23c81a to your computer and use it in GitHub Desktop.
This file contains 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 model_builder_HPARAMS(hparams): | |
model = keras.Sequential() | |
model.add(keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(150, 150, 3))) | |
model.add(keras.layers.MaxPooling2D(2, 2)) | |
# Tune the number of filters for the second Conv2D | |
# Choose an optimal value from 64-128 | |
model.add(keras.layers.Conv2D(hparams[HP_NUM_FILTERS], kernel_size=3, activation='relu')) | |
model.add(keras.layers.MaxPooling2D(2, 2)) | |
model.add(keras.layers.Flatten()) | |
# Tune the Dropout | |
# Choose an optimal value between 0.1-0.5 | |
model.add(keras.layers.Dropout(hparams[HP_DROPOUT])) | |
# Tune the number of units in the Dense layer | |
# Tune the activation function for Dense layer | |
# Choose an optimal value from relu, tanh, sigmoid | |
model.add(keras.layers.Dense(units = hparams[HP_NUM_UNITS], activation = hparams[HP_ACTIVATION])) | |
model.add(keras.layers.Dense(3, activation='softmax')) | |
# Choose ideal optimizer function | |
model.compile(optimizer = hparams[HP_OPTIMIZER], | |
loss = keras.losses.CategoricalCrossentropy(from_logits = True), | |
metrics = ['accuracy']) | |
model.fit(train_generator, | |
validation_data=validation_generator, | |
epochs=5) | |
_, accuracy = model.evaluate(validation_generator) | |
return accuracy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment