Skip to content

Instantly share code, notes, and snippets.

@jamesandersen
Created August 28, 2017 13:56
Show Gist options
  • Save jamesandersen/17acefc0d680729d7f8bf37f1654ac68 to your computer and use it in GitHub Desktop.
Save jamesandersen/17acefc0d680729d7f8bf37f1654ac68 to your computer and use it in GitHub Desktop.
Keras Neural Network Model for Lending Club Data
"""Create Keras model"""
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.constraints import maxnorm
def create_model(input_dim, output_dim):
# create model
model = Sequential()
# input layer
model.add(Dense(100, input_dim=input_dim, activation='relu', kernel_constraint=maxnorm(3)))
model.add(Dropout(0.2))
# hidden layer
model.add(Dense(60, activation='relu', kernel_constraint=maxnorm(3)))
model.add(Dropout(0.2))
# output layer
model.add(Dense(output_dim, activation='softmax'))
# Compile model
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
return model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment