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
#pm_view { | |
min-width:70%; | |
} | |
#conversation-list-columns{ | |
border-right:none; | |
background:#F7F6F6; | |
max-width:30%; | |
} | |
#conversation-view{ | |
min-width:68%; |
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
def import_embedding(embedding_name="data/default"): | |
if not embedding_name: | |
return None, None | |
file_flag = os.path.isfile(embedding_name+"_word_encoding.json") | |
file_flag &= os.path.isfile(embedding_name+"_cat_encoding.json") | |
if not file_flag: | |
return None, None |
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
if save_model_flag: | |
# Add optimization method, loss function and optimization value | |
model.compile(loss='categorical_crossentropy', | |
optimizer='adam', metrics=['accuracy']) | |
# "Fit the model" (train model), using training data (80% of datset) | |
model.fit(x_train, y_train, batch_size=batch_size, | |
epochs=epochs, validation_data=(x_test, y_test)) |
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
max_words, batch_size, maxlen, epochs, ngram_range = 10000, 32, 500, 5, 2 | |
# Determine the number of categories + default(i.e. sentence types) | |
num_classes = np.max(y_train) + 1 | |
# Vectorize the output sentence type classifcations to Keras readable format | |
y_train = keras.utils.to_categorical(y_train, num_classes) | |
y_test = keras.utils.to_categorical(y_test, num_classes) | |
if ngram_range > 1: |
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
max_words, batch_size, maxlen, epochs, ngram_range = 10000, 32, 500, 5, 2 | |
# Determine the number of categories + default(i.e. sentence types) | |
num_classes = np.max(y_train) + 1 | |
# Vectorize the output sentence type classifcations to Keras readable format | |
y_train = keras.utils.to_categorical(y_train, num_classes) | |
y_test = keras.utils.to_categorical(y_test, num_classes) | |
if ngram_range > 1: |
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
""" | |
Taken from: https://github.com/keras-team/keras | |
Based on Joulin et al's paper: | |
Bags of Tricks for Efficient Text Classification | |
https://arxiv.org/abs/1607.01759 | |
""" | |
def create_ngram_set(input_list, ngram_value=2): | |
""" | |
Extract a set of n-grams from a list of integers. |
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
import keras | |
from keras.preprocessing import sequence | |
from keras.models import Sequential | |
from keras.layers import Dense, Embedding,GlobalAveragePooling1D | |
model = Sequential() | |
# Created Embedding (Input) Layer (max_words) --> Pooling Layer | |
model.add(Embedding(max_words, embedding_dims, input_length=maxlen)) |
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
max_words, batch_size, maxlen, epochs = 10000, 64, 500, 2 | |
embedding_dims, filters, kernel_size, hidden_dims = 50, 250, 5, 150 | |
# Determine the number of categories + default(i.e. sentence types) | |
num_classes = np.max(y_train) + 1 | |
# Vectorize the output sentence type classifcations to Keras readable format | |
y_train = keras.utils.to_categorical(y_train, num_classes) | |
y_test = keras.utils.to_categorical(y_test, num_classes) |
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
import keras | |
from keras.preprocessing import sequence | |
from keras.models import Sequential | |
from keras.layers import Dense, Dropout, Activation | |
from keras.layers import Embedding, Conv1D, GlobalMaxPooling1D | |
model = Sequential() | |
# Created Embedding (Input) Layer (max_words) --> Convolutional Layer | |
model.add(Embedding(max_words, embedding_dims, input_length=maxlen)) |
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
max_words, batch_size, maxlen, epochs = 10000, 125, 500, 5 | |
# Determine the number of categories + default(i.e. sentence types) | |
num_classes = np.max(y_train) + 1 | |
# Vectorize the output sentence type classifcations to Keras readable format | |
y_train = keras.utils.to_categorical(y_train, num_classes) | |
y_test = keras.utils.to_categorical(y_test, num_classes) | |
# Pad the input vectors to ensure a consistent length |