Skip to content

Commit

Permalink
add codes
Browse files Browse the repository at this point in the history
  • Loading branch information
supercoderhawk committed Sep 25, 2017
1 parent 7159481 commit 0b98f7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def train_exe(self):
print(time.time() - last_time)
last_time = time.time()
if self.type == 'mlp':
self.saver.save(self.sess, 'tmp/mlp-ner-model%d.ckpt'.format(i+1))
self.saver.save(self.sess, 'tmp/lstm/mlp-ner-model%d.ckpt'.format(i+1))
elif self.type == 'lstm':
self.saver.save(self.sess, 'tmp/lstm-ner-model%d.ckpt'.format(i+1))
self.saver.save(self.sess, 'tmp/lstm/lstm-ner-model%d.ckpt'.format(i+1))
elif self.mode == TrainMode.Batch:
for i in range(epoches):
self.step = i
Expand All @@ -173,7 +173,7 @@ def train_exe(self):
print(batch_index)
print(time.time() - last_time)
last_time = time.time()
self.saver.save(self.sess, 'tmp/lstm-ner-model%d.ckpt'.format(i+1))
self.saver.save(self.sess, 'tmp/lstm/lstm-ner-model%d.ckpt'.format(i+1))

def train_sentence(self, sentence, labels):
scores = self.sess.run(self.word_scores, feed_dict={self.input: sentence})
Expand Down Expand Up @@ -278,5 +278,5 @@ def seg(self, sentence, model_path='tmp/mlp-model0.ckpt', debug=False, ner=False
if __name__ == '__main__':
dnn = DNN('mlp', mode=TrainMode.Sentence, task='ner')
dnn.train_exe()
dnn = DNN('lstm', mode=TrainMode.Sentence, task='ner')
dnn = DNN('lstm', task='ner')
dnn.train_exe()
2 changes: 1 addition & 1 deletion preprocess_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class PreprocessData:
def __init__(self, corpus, mode, type=CorpusType.Train,force_generate=True):
self.skip_window_left = 1
self.skip_window_left = 0
self.skip_window_right = 1
self.window_size = self.skip_window_left + self.skip_window_right + 1
self.dict_path = 'corpus/' + corpus + '_dict.utf8'
Expand Down

0 comments on commit 0b98f7a

Please sign in to comment.