From 0b98f7a009d051c3464c517e6a49e00004a5e0fd Mon Sep 17 00:00:00 2001 From: supercoderhawk Date: Mon, 25 Sep 2017 22:44:28 +0800 Subject: [PATCH] add codes --- dnn.py | 8 ++++---- preprocess_data.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dnn.py b/dnn.py index fea64ee..6fab522 100644 --- a/dnn.py +++ b/dnn.py @@ -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 @@ -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}) @@ -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() diff --git a/preprocess_data.py b/preprocess_data.py index 450ba34..6948eba 100644 --- a/preprocess_data.py +++ b/preprocess_data.py @@ -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'