-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_w2v_v2.py
139 lines (124 loc) · 3.31 KB
/
main_w2v_v2.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import os
import json
from train_network_w2v_v2 import trainNetwork
# get paths
home_path = os.getcwd()
results_path = home_path + '\\results\\'
# set filename
fname = 'training_v4'
fpath = results_path + fname
# init dictionary for saving
saveDict = {
'model_v400':{
'n_epochs':5,
'embeddings':True,
'embedding_dim':300,
'seq_length':100,
'units':[500]
},
# 'model_v01':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':50,
# 'units':[100, 100]
# },
# 'model_v02':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':50,
# 'units':[100, 50]
# },
# 'model_v03':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':50,
# 'units':[100, 100, 100]
# },
# 'model_v04':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':50,
# 'units':[100, 100, 50]
# },
# 'model_v05':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':50,
# 'units':[100, 100, 50, 50]
# },
# 'model_v06':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':100,
# 'units':[100]
# },
# 'model_v07':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':100,
# 'units':[100, 100]
# },
# 'model_v08':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':100,
# 'units':[100, 50]
# },
# 'model_v09':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':100,
# 'units':[100, 100, 100]
# },
# 'model_v010':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':100,
# 'units':[100, 100, 50]
# },
# 'model_v011':{
# 'n_epochs':2,
# 'embeddings':True,
# 'embedding_dim':100,
# 'seq_length':100,
# 'units':[100, 100, 50, 50]
# },
}
for model, params in saveDict.items():
n_epochs = params['n_epochs']
embeddings = params['embeddings']
embedding_dim = params['embedding_dim']
seq_length = params['seq_length']
units = params['units']
print('\n TRAIN NETWORK ({}): epochs: {}, seq_len: {}, embedding dims: {}, n. layers: {}\n'.format(
model,
n_epochs,
seq_length,
embedding_dim,
len(units)
))
# get training results
trainLossHist, valLossHist = trainNetwork(
n_epochs=n_epochs,
embeddings=embeddings,
embedding_dim=embedding_dim,
seq_length=seq_length,
units=units,
model_name=model
)
# save version-specific results in dictionary
saveDict[model]['trainLossHist'] = trainLossHist
saveDict[model]['valLossHist'] = valLossHist
# dump results to JSON
with open(fpath, 'w') as fp:
json.dump(saveDict, fp)