Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add informative comments #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions examples/keras_examples/optimization_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from keras.models import Sequential
from keras.wrappers.scikit_learn import KerasClassifier


## INITIAL HYPERPARAMETERS MODEL
def _build_fn_experiment(input_shape):
model = Sequential(
[
Expand All @@ -19,18 +19,20 @@ def _build_fn_experiment(input_shape):
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
return model


## HYPERPARAMETER OPTIMIZER
def _build_fn_optimization(input_shape):
model = Sequential(
[
Dense(
Integer(50, 150),
kernel_initializer="uniform",
input_shape=input_shape,
activation="relu",
Integer(50, 150), # TO OPTIMIZE: Dense 'units', from 50 to 150, in integer values
kernel_initializer="uniform", # FIXED (no optimization)
input_shape=input_shape, # FIXED
activation="relu", # FIXED
),
Dropout(Real(0.2, 0.7)),
Dense(1, kernel_initializer="uniform", activation=Categorical(["sigmoid", "relu"])),
Dropout(Real(0.2, 0.7)), # TO OPTIMIZE: Dropout rate, from 0.2 to 0.7, in real values
Dense(1, # FIXED
kernel_initializer="uniform", # FIXED
activation=Categorical(["sigmoid", "relu"])), # TO OPTIMIZE: Dense activation, one of "sigmoid", "relu"
]
)
model.compile(
Expand Down