我在运行时,报如下错误:
Traceback (most recent call last):
File "a2c-train.py", line 348, in
main()
File "a2c-train.py", line 330, in main
xent_trainer.train(opt.start_epoch, opt.start_reinforce - 1, start_time)
File "F:\code_summarization_public-master\lib\train\Trainer.py", line 30, in train
train_loss = self.train_epoch(epoch)
File "F:\code_summarization_public-master\lib\train\Trainer.py", line 103, in train_epoch
return total_loss / total_words
ZeroDivisionError: division by zero
failed.
您在实验中是否遇到类似的问题,希望您可以帮我解答一下,万分感谢!
number of parameters: 92592823
opt.eval: False
opt.eval_sample: False
supervised_data.src: 54426
supervised_data.tgt: 54426
supervised_data.trees: 54426
supervised_data.leafs: 54426
supervised training..
start_epoch: 1
XENT epoch *
Model optim lr: 0.001
<class 'lib.data.Dataset.Dataset'> 54426
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py:1351: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py:1340: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")
/content/drive/My Drive/notebooks/Python_method_name_prediction/code_summarization_public/lib/model/HybridAttention.py:34: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
attn_tree = self.sm(attn_tree)
/content/drive/My Drive/notebooks/Python_method_name_prediction/code_summarization_public/lib/model/HybridAttention.py:36: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
attn_txt = self.sm(attn_txt)
outputs: torch.Size([26, 32, 512])
/content/drive/My Drive/notebooks/Python_method_name_prediction/code_summarization_public/lib/metric/Loss.py:8: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
log_dist = F.log_softmax(logits)
loss value: 3042.23095703125
---else---
torch.Size([26, 32, 512])
torch.Size([26, 32, 512])
Traceback (most recent call last):
File "a2c-train.py", line 339, in
main()
File "a2c-train.py", line 321, in main
xent_trainer.train(opt.start_epoch, opt.start_reinforce - 1, start_time)
File "/content/drive/My Drive/notebooks/Python_method_name_prediction/code_summarization_public/lib/train/Trainer.py", line 30, in train
train_loss = self.train_epoch(epoch)
File "/content/drive/My Drive/notebooks/Python_method_name_prediction/code_summarization_public/lib/train/Trainer.py", line 85, in train_epoch
loss = self.model.backward(outputs, targets, weights, num_words, self.loss_func)
File "/content/drive/My Drive/notebooks/Python_method_name_prediction/code_summarization_public/lib/model/EncoderDecoder.py", line 547, in backward
outputs.backward(grad_output)
File "/usr/local/lib/python3.6/dist-packages/torch/tensor.py", line 195, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/usr/local/lib/python3.6/dist-packages/torch/autograd/init.py", line 99, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: Function CatBackward returned an invalid gradient at index 1 - got [85, 1, 512] but expected shape compatible with [57, 1, 512]
failed.
您好,您论文中 We can see that the actor and critic networks share the modules (a)-(b)-(c), reducing the number of learning parameters a lot. 意思是它俩共享参数吗?如果是的话,我在代码中好像没有看到;如果不是的话,请问您这是什么意思?
Get this error on running the testing part (tried it on two separate systems to get the same error):
Start...
vocabulary size. source = 50004; target = 31280
number of XENT training sentences. 1000
number of PG training sentences. 1000
maximum batch size. 64
Building model...
('use_critic: ', False)
Loading from checkpoint at /media/BACKUP/ghproj_d/code_summarization/github-python/result/model_rf_hybrid_1_29_reinforce.pt
Traceback (most recent call last):
File "a2c-train.py", line 349, in
main()
File "a2c-train.py", line 254, in main
checkpoint = torch.load(opt.load_from, map_location=lambda storage, loc: storage)
File "/usr/local/lib/python2.7/dist-packages/torch/serialization.py", line 231, in load
return _load(f, map_location, pickle_module)
File "/usr/local/lib/python2.7/dist-packages/torch/serialization.py", line 369, in _load
magic_number = pickle_module.load(f)
cPickle.UnpicklingError: could not find MARK