Created
August 28, 2017 13:56
-
-
Save jamesandersen/17acefc0d680729d7f8bf37f1654ac68 to your computer and use it in GitHub Desktop.
Keras Neural Network Model for Lending Club Data
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
"""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