-
Notifications
You must be signed in to change notification settings - Fork 13
/
train_test.py
80 lines (73 loc) · 4.79 KB
/
train_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! -*- coding: utf-8 -*-
from preprocess import *
from model_train import *
data_file = 'data/comments_words_clean_sample.csv'
word2vec_file = 'model/word2vec_skip_128.bin'
max_num_words = 70000
max_text_word = 75
x_train, y_train, x_test, y_test, embedding_matrix, embedding_layer = build_data(
data_file=data_file, word2vec_file=word2vec_file, max_num_words=max_num_words,
max_text_word=max_text_word, classes=[1, 5], vector=False)
print('train biLSTM model of score 1,5 .....')
biLSTM_train(x_train, y_train, x_test, y_test, input_shape=(max_text_word, 128), embedding_layer=embedding_layer,
model_name='score_1_5')
print('train CNN1D model of score 1,5 .....')
CNN1D_train(x_train, y_train, x_test, y_test, max_text_word=max_text_word, embedding_layer=embedding_layer,
model_name='score_1_5')
print('train LSTM model of score 1,5 .....')
LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_1_5')
print('train CNN_LSTM model of score 1,5 .....')
CNN_LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_1_5')
print('train GRU_Capsule model of score 1,5 .....')
GRU_Capsule_train(x_train, y_train, x_test, y_test, gru_len=128, embedding_layer=embedding_layer,
model_name='score_1_5')
print('train Attention model of score 1,5 .....')
attention_train(x_train,y_train,x_test,y_test,embedding_layer=embedding_layer,model_name='score_1_5')
x_train, y_train, x_test, y_test, embedding_matrix, embedding_layer = build_data(
data_file=data_file, word2vec_file=word2vec_file, max_num_words=max_num_words,
max_text_word=max_text_word, classes=[1, 3, 5], vector=False)
print('train biLSTM model of score 1,3,5 .....')
biLSTM_train(x_train, y_train, x_test, y_test, input_shape=(max_text_word, 128), embedding_layer=embedding_layer,
model_name='score_1_3_5')
print('train CNN1D model of score 1,3,5 .....')
CNN1D_train(x_train, y_train, x_test, y_test, max_text_word=max_text_word, embedding_layer=embedding_layer,
model_name='score_1_3_5')
print('train LSTM model of score 1,3,5 .....')
LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_1_3_5')
print('train CNN_LSTM model of score 1,3,5 .....')
CNN_LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_1_3_5')
print('train GRU_Capsule model of score 1,3,5 .....')
GRU_Capsule_train(x_train, y_train, x_test, y_test, gru_len=128, embedding_layer=embedding_layer,
model_name='score_1_3_5')
x_train, y_train, x_test, y_test, embedding_matrix, embedding_layer = build_data(
data_file=data_file, word2vec_file=word2vec_file, max_num_words=max_num_words,
max_text_word=max_text_word, classes=[2, 4], vector=False)
print('train biLSTM model of score 2,4 .....')
biLSTM_train(x_train, y_train, x_test, y_test, input_shape=(max_text_word, 128), embedding_layer=embedding_layer,
model_name='score_2_4')
print('train CNN1D model of score 2,4 .....')
CNN1D_train(x_train, y_train, x_test, y_test, max_text_word=max_text_word, embedding_layer=embedding_layer,
model_name='score_2_4')
print('train LSTM model of score 2,4 .....')
LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_2_4')
print('train CNN_LSTM model of score 2,4 .....')
CNN_LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_2_4')
print('train GRU_Capsule model of score 2,4 .....')
GRU_Capsule_train(x_train, y_train, x_test, y_test, gru_len=128, embedding_layer=embedding_layer,
model_name='score_2_4')
x_train, y_train, x_test, y_test, embedding_matrix, embedding_layer = build_data(
data_file=data_file, word2vec_file=word2vec_file, max_num_words=max_num_words,
max_text_word=max_text_word, classes=[1, 2, 3, 4, 5], vector=False)
print('train biLSTM model of score 1,2,3,4,5 .....')
biLSTM_train(x_train, y_train, x_test, y_test, input_shape=(max_text_word, 128), embedding_layer=embedding_layer,
model_name='score_1_2_3_4_5')
print('train CNN1D model of score 1,2,3,4,5 .....')
CNN1D_train(x_train, y_train, x_test, y_test, max_text_word=max_text_word, embedding_layer=embedding_layer,
model_name='score_1_2_3_4_5')
print('train LSTM model of score 1,2,3,4,5 .....')
LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_1_2_3_4_5')
print('train CNN_LSTM model of score 1,2,3,4,5 .....')
CNN_LSTM_train(x_train, y_train, x_test, y_test, embedding_layer=embedding_layer, model_name='score_1_2_3_4_5')
print('train GRU_Capsule model of score 1,2,3,4,5 .....')
GRU_Capsule_train(x_train, y_train, x_test, y_test, gru_len=128, embedding_layer=embedding_layer,
model_name='score_1_2_3_4_5')