thu-coai / NAST

Codes for "NAST: A Non-Autoregressive Generator with Word Alignment for Unsupervised Text Style Transfer" (ACL 2021 findings)
MIT License
15 stars 1 forks source link

a problem when running run.py #4

Open li-jing-wen opened 1 year ago

li-jing-wen commented 1 year ago

When running run.py, there is an issue IndexError: invalid index to scalar variable. It seems to be the dimension problem of the weights, I don't understand it, may I ask how to solve this problem? The following error message is displayed: Traceback (most recent call last): File "/root/nas/NAST/styletransformer/run.py", line 161, in run(*sys.argv[1:]) File "/root/nas/NAST/styletransformer/run.py", line 157, in run main(args) File "/root/nas/NAST/styletransformer/main.py", line 71, in main model.train_process() File "/root/nas/NAST/styletransformer/seq2seq.py", line 90, in train_process devloss_detail = self.evaluate("dev", hasref=False, write_output=False) File "/root/nas/NAST/styletransformer/seq2seq.py", line 356, in evaluate result0 = inference(datakey, 0) File "/root/nas/NAST/styletransformer/seq2seq.py", line 341, in inference result = metric.close() File "/opt/conda/envs/torch/lib/python3.9/site-packages/cotk/metric/metric.py", line 242, in close res.update(metric.close()) File "/root/nas/NAST/styletransformer/../utils/cotk_private/metric/name_changer.py", line 14, in close return {self.prefix + key: value for key, value in self.target.close().items()} File "/opt/conda/envs/torch/lib/python3.9/site-packages/cotk/metric/bleu.py", line 189, in close corpus_bleu(self.refs, self.hyps, weights=weights, smoothing_function=SmoothingFunction().method3), \ File "/opt/conda/envs/torch/lib/python3.9/site-packages/nltk/translate/bleu_score.py", line 200, in corpus_bleu weights[0][0] IndexError: invalid index to scalar variable.

hzhwcmhf commented 1 year ago

@xiaowen3679 Hi, can you try downgrading the nltk to the version 3.4.5? You can use the following commands:

pip install nltk==3.4.5 --force-reinstall