This repository has been archived by the owner on Feb 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_now.py
145 lines (130 loc) · 5.32 KB
/
tag_now.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
140
141
142
143
144
145
from tagger import logger, network
from tagger.representation import postags
from tagger.utils import (
load_tagged_files,
all_postwita_tggd_flocs,
all_postwita_tst_flocs,
# all_gold_flocs,
load_tiger_vrt_file,
process_test_data_tagging
)
# import numpy as np
logger.info('Starting experient.')
retres = []
# postagstype_ibk = postags.PosTagsType(feature_type="ibk")
# postagstype_ibk_used = postags.PosTagsType(feature_type="ibk_used")
# postagstype_tiger_used = postags.PosTagsType(feature_type="1999_used")
postagstype = postags.PosTagsType(feature_type="postwita")
toks, tags = load_tagged_files(all_postwita_tggd_flocs)
# toks_trial, tags_trial = load_tagged_files(all_trial_tggd_flocs)
# toks_gold, tags_gold = load_tagged_files(all_gold_flocs)
toks_tig, tags_tig = load_tiger_vrt_file(
fileloc='../data/postwita/ud-treebanks-v1.3-it_didi-postrain.vrt.bz2')
dropout = 0.1
nb_epoch = 20
batch_size = 20
model = network.build_nn(output_dim=postagstype.feature_length,
lstm_output_dim=1024, dropout=dropout)
try:
model.save_weights('/global/lv70912/estemle/emptig_plain.hdf5',
overwrite=True)
except:
pass
network.train_nn(model, toks, tags, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emp_trained.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emp")
# res_emp2 = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emp2))
# retres.append(('emp', res_emp2))
# ##
batch_size = 50
network.train_nn(model, toks_tig, tags_tig, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emptig_retrained-0.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emptig")
# res_emptig = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emptig))
# retres.append(('emptig', res_emptig))
# ## ###
batch_size = 20
network.train_nn(model, toks, tags, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emptig_retrained-1.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emptigemp1")
# res_emptigemp = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emptigemp))
# retres.append(('emptigemp', res_emptigemp))
network.train_nn(model, toks, tags, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emptig_retrained-2.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emptigemp2")
# res_emptigempemp = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emptigempemp))
# retres.append(('emptigempemp', res_emptigempemp))
network.train_nn(model, toks, tags, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emptig_retrained-3.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emptigemp3")
# res_emptigempempemp = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emptigempempemp))
# retres.append(('emptigempempemp', res_emptigempempemp))
network.train_nn(model, toks, tags, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emptig_retrained-4.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emptigemp4")
# res_emptigemp4 = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emptigemp4))
# retres.append(('emptigemp4', res_emptigemp4))
network.train_nn(model, toks, tags, batch_size=batch_size,
nb_epoch=nb_epoch, postagstype=postagstype)
try:
model.save_weights('/global/lv70912/estemle/emptig_retrained-5.hdf5',
overwrite=True)
except:
pass
process_test_data_tagging(model, postagstype, all_postwita_tst_flocs,
extension=".emptigemp5")
# res_emptigemp5 = network.eval_nn(model, toks_gold, tags_gold,
# postagstype=postagstype)
# logger.info(network.compact_res(res_emptigemp5))
# retres.append(('emptigemp5', res_emptigemp5))
# ## ###
print(retres)
exit(0)