Skip to content

Instantly share code, notes, and snippets.

Last active June 17, 2019 10:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save KhyatiMahendru/312a6d0f2cfe03e9f0f3964bf2e54460 to your computer and use it in GitHub Desktop.
# importing requirements
from keras.layers import Dense
from keras.models import Sequential
from keras.optimizers import adam
# alpha = 0.001 as given in the lr parameter in adam() optimizer
# build the model
model_alpha1 = Sequential()
model_alpha1.add(Dense(50, input_dim=2, activation='relu'))
model_alpha1.add(Dense(3, activation='softmax'))
# compile the model
opt_alpha1 = adam(lr=0.001)
model_alpha1.compile(loss='categorical_crossentropy', optimizer=opt_alpha1, metrics=['accuracy'])
# fit the model
# dummy_Y is the one-hot encoded
# history_alpha1 is used to score the validation and accuracy scores for plotting
history_alpha1 =, dummy_Y, validation_data=(dataX, dummy_Y), epochs=200, verbose=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment