Skip to content

Commit

Permalink
masic dense model finished
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredfrancis committed May 14, 2018
1 parent a7d0890 commit 99551e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions app/nlu/classifiers/tf_intent_classifer.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import numpy as np
import tensorflow as tf
import spacy
from sklearn.preprocessing import LabelBinarizer
import os
import cloudpickle
import time

import numpy as np
np.random.seed(1)

class TfIntentClassifier():

def __init__(self):
self.model = None
self.nlp = spacy.load('en')
self.label_encoder = LabelBinarizer()
self.graph=None
print("im executed")

def train(self, X, y, models_dir=None, verbose=True):
"""
Expand All @@ -31,11 +32,15 @@ def create_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(num_labels, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(256, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(num_labels, activation=tf.nn.softmax))

"""
loss functions tried => categorical_crossentropy,binary_crossentropy
optimizers tried => adam,rmsprop
"""
model.compile(loss='categorical_crossentropy',
optimizer='rmsprop',
optimizer='adam',
metrics=['accuracy'])

model.summary()
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=False, threaded=False)
app.run(host='0.0.0.0', port=8080, debug=True, threaded=False)

0 comments on commit 99551e1

Please sign in to comment.