From d6c613e7f5fc5f8e589a0aa913d5fc830f1f94f7 Mon Sep 17 00:00:00 2001 From: ohazyi <291045048@qq.com> Date: Thu, 17 Jan 2019 00:31:20 +0800 Subject: [PATCH] questions on running the code I run the code, but encounter an error in Line35 in sample.py. "name 'vocab' is not defined" I checked that there seemed no variables named vocab, am i wrong or there existed some typo bugs? --- pytorch/sample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch/sample.py b/pytorch/sample.py index 31280e3..6952f88 100644 --- a/pytorch/sample.py +++ b/pytorch/sample.py @@ -32,7 +32,7 @@ def evaluate(model, metrics, test_loader, vocab_desc, vocab_api, f_eval, repeat) # nparray: [repeat x seq_len] pred_sents, _ = indexes2sent(sample_words, vocab_api) pred_tokens = [sent.split(' ') for sent in pred_sents] - ref_str, _ =indexes2sent(apiseqs[0].numpy(), vocab_api, vocab[""]) + ref_str, _ =indexes2sent(apiseqs[0].numpy(), vocab_api, vocab[""]) #vocab do not find??? ref_tokens = ref_str.split(' ') max_bleu, avg_bleu = metrics.sim_bleu(pred_tokens, ref_tokens)