Onion12138 / CasRelPyTorch

Reimplement CasRel model in PyTorch.使用PyTorch对吉林大学CasRel模型进行复现,并在百度关系抽取数据集上训练测试。
184 stars 26 forks source link

更换数据集的问题 #17

Open GekiKaraa opened 1 year ago

GekiKaraa commented 1 year ago

你好!我按照readme里面的格式定义了我的数据集,但是运行时在loss_fn中计算predict['obj_heads']的时候会出现传入的gold参数tensor多出一维的问题,使用code中自带的baidu数据集就不会出现这种情况,数据的格式都是一样的,请问这是因为处理过程有什么不同吗? 具体报错信息如下:

File "/CasRelPyTorch/Run.py", line 38, in loss_fn
    loss = F.binary_cross_entropy(pred, gold, reduction='none')

File "/python3.7/site-packages/torch/nn/functional.py", line 2752, in binary_cross_entropy
    "Please ensure they have the same size.".format(target.size(), input.size())

ValueError: Using a target size (torch.Size([8, 148, 1])) that is different to the input size (torch.Size([8, 148])) is deprecated. Please ensure they have the same size.
ericzikun commented 1 year ago

你好!我按照readme里面的格式定义了我的数据集,但是运行时在loss_fn中计算predict['obj_heads']的时候会出现传入的gold参数tensor多出一维的问题,使用code中自带的baidu数据集就不会出现这种情况,数据的格式都是一样的,请问这是因为处理过程有什么不同吗? 具体报错信息如下:

File "/CasRelPyTorch/Run.py", line 38, in loss_fn
    loss = F.binary_cross_entropy(pred, gold, reduction='none')

File "/python3.7/site-packages/torch/nn/functional.py", line 2752, in binary_cross_entropy
    "Please ensure they have the same size.".format(target.size(), input.size())

ValueError: Using a target size (torch.Size([8, 148, 1])) that is different to the input size (torch.Size([8, 148])) is deprecated. Please ensure they have the same size.

我跟你一样的问题,请问你解决了吗?

258508 commented 1 year ago

你好,请问解决了吗