Skip to content

Commit

Permalink
added dropouts to reduce overfitting
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredfrancis committed May 16, 2018
1 parent b6eb63e commit 3f25b01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/nlu/classifiers/tf_intent_classifer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def create_model():
Define and return tensorflow model.
"""
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(512, activation=tf.nn.relu, input_shape=(vocab_size,)))
model.add(tf.keras.layers.Dense(256, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(256, activation=tf.nn.relu, input_shape=(vocab_size,)))
model.add(tf.keras.layers.Dropout(0.2))
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dropout(0.2))
model.add(tf.keras.layers.Dense(num_labels, activation=tf.nn.softmax))

"""
Expand Down Expand Up @@ -64,7 +66,7 @@ def create_model():

self.model = create_model()
# start training
self.model.fit(x_train, y_train, shuffle=True, epochs=50, verbose=1)
self.model.fit(x_train, y_train, shuffle=True, epochs=300, verbose=1)

if models_dir:
tf.keras.models.save_model(
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from app import app

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True, threaded=False)
app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)

0 comments on commit 3f25b01

Please sign in to comment.