Traceback (most recent call last):
File "run_model.py", line 407, in
main(parse_args())
File "run_model.py", line 346, in main
train_kg_batch(args,kg_object_dict[args.target_language], optimizer, args.epoch10, model)
File "run_model.py", line 195, in train_kg_batch
loss = model.forward_kg(h_graph,kg_batch_each,t_graph,t_neg_graph)
File "/hy-tmp/src/ssaga_model.py", line 186, in forward_kg
total_loss = self.criterion_KG(pos_loss, neg_loss, target)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/loss.py", line 1323, in forward
return F.margin_ranking_loss(input1, input2, target, margin=self.margin, reduction=self.reduction)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py", line 3313, in margin_ranking_loss
raise RuntimeError(
RuntimeError: margin_ranking_loss : All input tensors should have same dimension but got sizes: input1: torch.Size([200, 1]), input2: torch.Size([200]), target: torch.Size([1])
您好,我在运行默认实例的时候遇到了一个问题,Traceback如下:
Traceback (most recent call last): File "run_model.py", line 407, in
main(parse_args())
File "run_model.py", line 346, in main
train_kg_batch(args,kg_object_dict[args.target_language], optimizer, args.epoch10, model)
File "run_model.py", line 195, in train_kg_batch
loss = model.forward_kg(h_graph,kg_batch_each,t_graph,t_neg_graph)
File "/hy-tmp/src/ssaga_model.py", line 186, in forward_kg
total_loss = self.criterion_KG(pos_loss, neg_loss, target)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/loss.py", line 1323, in forward
return F.margin_ranking_loss(input1, input2, target, margin=self.margin, reduction=self.reduction)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py", line 3313, in margin_ranking_loss
raise RuntimeError(
RuntimeError: margin_ranking_loss : All input tensors should have same dimension but got sizes: input1: torch.Size([200, 1]), input2: torch.Size([200]), target: torch.Size([1])
似乎是输入的torch.size不一致