Example #1
0
# train_reviews = np.load("../../Yelp_useful_train_fulltext_glove_300_X.npy")
# train_labels = np.load("../../Yelp_useful_train_fulltext_glove_300_y.npy")
# test_reviews = np.load("../../Yelp_useful_test_fulltext_glove_300_X.npy")
# test_labels = np.load("../../Yelp_useful_test_fulltext_glove_300_y.npy")

train_reviews = np.load("../../Yelp_cool_train_fulltext_glove_300_X.npy")
train_labels = np.load("../../Yelp_cool_train_fulltext_glove_300_y.npy")
test_reviews = np.load("../../Yelp_cool_test_fulltext_glove_300_X.npy")
test_labels = np.load("../../Yelp_cool_test_fulltext_glove_300_y.npy")

WV_FILE_GLOBAL = path_join(ROOT_PATH, "embeddings/wv/glove.42B.300d.120000-glovebox.pkl")

gb_global = pickle.load(open(WV_FILE_GLOBAL, "rb"))

wv_size = gb_global.W.shape[1]

model = Sequential()
model.add(
    make_embedding(vocab_size=gb_global.W.shape[0], init=gb_global.W, wv_size=wv_size, fixed=True, constraint=None)
)
model.add(GRU(128, init="uniform"))
model.add(Dropout(0.2))
model.add(Dense(1, init="uniform"))
model.add(Activation("sigmoid"))

model.compile(loss="binary_crossentropy", optimizer="adam", class_mode="binary")

history = train_neural.train_sequential(model, train_reviews, train_labels, MODEL_FILE)
acc = train_neural.test_sequential(model, test_reviews, test_labels, MODEL_FILE)
train_neural.write_log(model, history, __file__, acc, LOG_FILE)
Example #2
0
model.add(Activation('relu'))
model.add(Dropout(0.2))

model.add(Dense(25))
model.add(Activation('relu'))
model.add(Dropout(0.2))

model.add(Dense(10))
model.add(Activation('relu'))
model.add(Dropout(0.2))

#model.add(MaxoutDense(1, 1)) # SALE 1
model.add(Dense(5))
model.add(Activation('relu'))
# model_basic.add(Dropout(0.1))

model.add(Dense(1))
model.add(Activation('tanh'))

# model_basic.add(Dense(10, 1))
# model_basic.add(Activation('relu'))

model.compile(loss='binary_crossentropy',
              optimizer="adam",
              class_mode="binary")

history = train_neural.train_sequential(model, X_train, train_labels,
                                        MODEL_FILE)
acc = train_neural.test_sequential(model, X_test, test_labels, MODEL_FILE)
train_neural.write_log(model, history, __file__, acc, LOG_FILE)
Example #3
0
model.add(Activation('relu'))
model.add(Dropout(0.5))

model.add(Convolution1D(128, 3, subsample_length=2, init='he_uniform'))
model.add(Activation('relu'))
model.add(Dropout(0.5))

model.add(Convolution1D(128, 3, subsample_length=2, init='he_uniform'))
model.add(Activation('relu'))
model.add(Dropout(0.5))

model.add(Convolution1D(128, 3, subsample_length=2, init='he_uniform'))
model.add(Activation('relu'))
model.add(Dropout(0.5))

model.add(Flatten())

model.add(Dense(64, activation='relu'))

model.add(Dropout(0.25))

model.add(Dense(1, init='he_uniform'))
model.add(Activation('sigmoid'))

#sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='binary_crossentropy', optimizer="adam", class_mode="binary")

history = train_neural.train_sequential(model, train_reviews, train_labels, MODEL_FILE)
acc = train_neural.test_sequential(model, test_reviews, test_labels, MODEL_FILE)
train_neural.write_log(model, history, __file__, acc, LOG_FILE)
Example #4
0
model.add(Dense(50))
model.add(Activation('relu'))
model.add(Dropout(0.2))

model.add(Dense(25))
model.add(Activation('relu'))
model.add(Dropout(0.2))

model.add(Dense(10))
model.add(Activation('relu'))
model.add(Dropout(0.2))


#model.add(MaxoutDense(1, 1)) # SALE 1
model.add(Dense(5))
model.add(Activation('relu'))
# model_basic.add(Dropout(0.1))

model.add(Dense(1))
model.add(Activation('tanh'))

# model_basic.add(Dense(10, 1))
# model_basic.add(Activation('relu'))

model.compile(loss='binary_crossentropy', optimizer="adam", class_mode="binary")


history = train_neural.train_sequential(model, X_train, train_labels, MODEL_FILE)
acc = train_neural.test_sequential(model, X_test, test_labels, MODEL_FILE)
train_neural.write_log(model, history, __file__, acc, LOG_FILE)