Graph-to-seq-comment-generation
Graph-to-seq-comment-generation copied to clipboard
run error
Traceback (most recent call last):
File "train.py", line 299, in
出现上述错误是因为什么呢? 跪求解答
同问,而且“segged_content.txt”是如何获得的
可以通过从json文件中抽取
Traceback (most recent call last): File "train.py", line 299, in main() File "train.py", line 291, in main max_bleu = train(model, vocab, dataloader, scheduler, optim, updates) File "train.py", line 118, in train outputs = model(batch, use_cuda) File "/opt/lang.huo/miniconda3/envs/huopei/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/opt/lang.huo/mybot/question_generation/models/graph2seq.py", line 93, in forward contexts, state, attns = self.encode(src, src_mask, concept, concept_mask, title_index, adjs) File "/opt/lang.huo/mybot/question_generation/models/graph2seq.py", line 71, in encode return contexts, state, attn UnboundLocalError: local variable 'attn' referenced before assignment
出现上述错误是因为什么呢? 跪求解答
需要预先定义一下,大概是代码中漏定义了。 def encode(self, contents, contents_mask, concepts, concept_mask, title_index, adjs): contexts = [] states = [] attn=[] ……
attn可以直接删去,这个是分析的时候看attention 权重的发自我的华为手机-------- 原始邮件 --------主题:Re: [lancopku/Graph-to-seq-comment-generation] run error (#7)发件人:shenjian5 收件人:lancopku/Graph-to-seq-comment-generation 抄送:Subscribed
Traceback (most recent call last):
File "train.py", line 299, in
main()
File "train.py", line 291, in main
max_bleu = train(model, vocab, dataloader, scheduler, optim, updates)
File "train.py", line 118, in train
outputs = model(batch, use_cuda)
File "/opt/lang.huo/miniconda3/envs/huopei/lib/python3.6/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/opt/lang.huo/mybot/question_generation/models/graph2seq.py", line 93, in forward
contexts, state, attns = self.encode(src, src_mask, concept, concept_mask, title_index, adjs)
File "/opt/lang.huo/mybot/question_generation/models/graph2seq.py", line 71, in encode
return contexts, state, attn
UnboundLocalError: local variable 'attn' referenced before assignment
出现上述错误是因为什么呢?
跪求解答
需要预先定义一下,大概是代码中漏定义了。
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/lancopku/Graph-to-seq-comment-generation/issues/7#issuecomment-660855293",
"url": "https://github.com/lancopku/Graph-to-seq-comment-generation/issues/7#issuecomment-660855293",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]