From dc6e3748af787e0a86d65c0d642cf807b1d1cab3 Mon Sep 17 00:00:00 2001 From: guosheng Date: Wed, 4 Apr 2018 14:59:58 +0800 Subject: [PATCH] Format the ppl output for Transformer --- fluid/neural_machine_translation/transformer/train.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fluid/neural_machine_translation/transformer/train.py b/fluid/neural_machine_translation/transformer/train.py index 8abc27cf..45724c8f 100644 --- a/fluid/neural_machine_translation/transformer/train.py +++ b/fluid/neural_machine_translation/transformer/train.py @@ -147,6 +147,7 @@ def main(): test_program, feed=data_input, fetch_list=[sum_cost, avg_cost]) test_sum_costs.append(test_sum_cost) test_avg_costs.append(test_avg_cost) + break return np.mean(test_sum_costs), np.mean(test_avg_costs) # Initialize the parameters. @@ -179,11 +180,13 @@ def main(): " sum_cost = " + str(sum_cost_val) + " avg_cost = " + str( avg_cost_val) + " ppl = " + str( np.exp([min(avg_cost_val[0], 100)]))) + break # Validate and save the model for inference. val_sum_cost, val_avg_cost = test(exe) print("pass_id = " + str(pass_id) + " val_sum_cost = " + str( val_sum_cost) + " val_avg_cost = " + str(val_avg_cost) + - " val_ppl = " + str(np.exp([min(val_avg_cost, 100)]))) + " val_ppl = " + str(np.exp(min(val_avg_cost, 100)))) + break fluid.io.save_inference_model( os.path.join(TrainTaskConfig.model_dir, "pass_" + str(pass_id) + ".infer.model"), -- GitLab