diff --git a/src/params.json b/src/params.json index 248f2d0..a6ae0fb 100644 --- a/src/params.json +++ b/src/params.json @@ -1,10 +1,10 @@ { "bidirectional": true, - "use_residual": false, - "use_dropout": false, - "time_major": false, + "use_residual": true, + "use_dropout": true, + "time_major": true, "cell_type": "lstm", - "depth": 2, + "depth": 4, "attention_type": "Bahdanau", "hidden_units": 128, "optimizer": "adam", diff --git a/src/test.py b/src/test.py index 40481c4..9da9512 100644 --- a/src/test.py +++ b/src/test.py @@ -29,8 +29,8 @@ def test(params): ) # 读取模型路径 - # save_path = './model/s2ss_chatbot_anti.ckpt' - save_path = './model/s2ss_chatbot.ckpt' + save_path = './model/s2ss_chatbot_anti.ckpt' + # save_path = './model/s2ss_chatbot.ckpt' tf.reset_default_graph() model_pred = SequenceToSequence( diff --git a/src/train_anti.py b/src/train_anti.py index 93819ae..cdb6727 100644 --- a/src/train_anti.py +++ b/src/train_anti.py @@ -20,7 +20,7 @@ def test(params): x_data, y_data = pickle.load(open('chatbot.pkl', 'rb')) ws = pickle.load(open('ws.pkl', 'rb')) - n_epoch = 2 # 训练轮次 + n_epoch = 40 # 训练轮次 batch_size = 128 steps = int(len(x_data) / batch_size) + 1 diff --git a/src/web.py b/src/web.py index 0f507d4..7ae5c1a 100644 --- a/src/web.py +++ b/src/web.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ - Description : train_anti 测试 + Description : web interface Author : xxm """ import sys @@ -18,9 +18,6 @@ def test(params, infos): x_data, _ = pickle.load(open('chatbot.pkl', 'rb')) ws = pickle.load(open('ws.pkl', 'rb')) - for x in x_data[:5]: - print(' '.join(x)) - config = tf.ConfigProto( device_count={'CPU': 1, 'GPU': 0}, allow_soft_placement=True, @@ -50,8 +47,6 @@ def test(params, infos): x, xl = next(bar) x = np.flip(x, axis=1) - print(x, xl) - pred = model_pred.predict( sess, np.array(x), @@ -59,8 +54,6 @@ def test(params, infos): ) print(pred) - print(ws.inverse_transform(x[0])) - for p in pred: ans = ws.inverse_transform(p) print(ans)