Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# 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