DreamInvoker / GAIN

Source code for EMNLP 2020 paper: Double Graph Based Reasoning for Document-level Relation Extraction
MIT License
142 stars 31 forks source link

关于其他数据集的修改: #20

Closed Emir-Liu closed 3 years ago

Emir-Liu commented 3 years ago

我修改了自己的数据集使得其符合格式,然后修改'config.py'中的relation_nums为2,但是训练的时候仍然出错了。 错误报告如下

Traceback (most recent call last):
  File "train.py", line 194, in <module>
    train(opt)
  File "train.py", line 106, in train
    loss = torch.sum(BCE(predictions, relation_multi_label) * relation_mask.unsqueeze(2))/(opt.relation_nums * torch.sum(relation_mask))
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/loss.py", line 717, in forward
    reduction=self.reduction)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 2824, in binary_cross_entropy_with_logits
    raise ValueError("Target size ({}) must be the same as input size ({})".format(target.size(), input.size()))
ValueError: Target size (torch.Size([1, 21, 97])) must be the same as input size (torch.Size([1, 21, 2]))
end