CG-RL
CG-RL copied to clipboard
Got TypeError when pre-trainning model
Hi, when pre-trainning model, I got TypeError as the following:
Traceback (most recent call last): File "exp.py", line 615, in
pretrain(args) File "exp.py", line 530, in pretrain verbose=True, eval_top_pred_only=args.eval_top_pred_only) File "/home/vladimir/cg-rl/CG-RL-main/evaluation.py", line 65, in evaluate decode_results = decode(examples, parser, args, verbose=False) File "/home/vladimir/cg-rl/CG-RL-main/evaluation.py", line 26, in decode hyps = model.parse(example.src_sent, context=None, beam_size=args.beam_size) File "/home/vladimir/cg-rl/CG-RL-main/model/parser_pre.py", line 777, in parse token = primitive_vocab.id2word[token_id.item()] TypeError: 'method' object is not subscriptable
After checking the class VocabEntry
I found the member variable id2word
defined in line 18 has the same name with the member method defined in line 35. I think the member method is redundant and should be removed. Is it right? @lighter47
No, this class is from Tranx and no problem. I can't tell the reason, maybe you can send me more information via email.
Uhh, I don't know the reason, too. I met this problem when using the dataset built by myself. The environment is the same as your Python3 environment. However, I think the member method id2word
in line 35 of the file components/vocab.py
is redundant, and removing it could solve this problem.
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2022年4月12日(星期二) 晚上7:58 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [DeepLearnXMU/CG-RL] Got TypeError when pre-trainning model (Issue #4)
No, this class is from Tranx and no problem. I can't tell the reason, maybe you can send me more information via email.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Ok I found the reason. I process my dataset using the latest version of tranx, but the file components/vocab.py
in your code is the previous version of tranx. There are some differences between the two versions in the class VocabEntry
.
And I found the package dataset
should be in your code. Could you please add the package to your code? @lighter47
have you solved this problem? @Vladimir-Chan
have you solved this problem? @Vladimir-Chan
If I remember correctly, using Pytorch 1.3.0 may be helpful.