Closed liyao345496280 closed 1 year ago
看这个错误一般下标越界,你这个是一上来直接报错,还是能跑几个batch再报错,另外你可以try catch打印一下计算loss错误时候,y_true和y_pred的情况
这是debug出来的出错地方,在这个SparseMultilabelCategoricalCrossentropy类里面。
这是此时的y_true和y_pred的情况,其中我把batchsize设置为8。
这应该是一上来就报的错,这个MyLoss中的forward函数第一次调用的时候就报了错
我看这个y_true里面有-1,这个应该不太对吧
请问一下,您代码里的那个数据集,我在官网上没找到它的验证集,请问大佬能否提供一下,我对比下数据集
好的,我晚上贴一下~
请问一下,您代码里的那个数据集,我在官网上没找到它的验证集,请问大佬能否提供一下,我对比下数据集
谢谢您
Nier @.***
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年5月18日(星期四) 晚上8:31 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Tongjilibo/bert4torch] GPLinker的中的MyLoss类下出现的问题 (Issue #132)
请问一下,您代码里的那个数据集,我在官网上没找到它的验证集,请问大佬能否提供一下,我对比下数据集
数据集-百度云链接
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
提问时请尽可能提供如下信息:
基本信息
核心代码
输出信息
自我尝试
我尝试了将y_pred,y_true转换为CPU中再进行运行,结果显示的报错是
Traceback (most recent call last): File "D:\LY\RE\test.py", line 266, in
model.fit(train_dataloader, steps_per_epoch=None, epochs=20, callbacks=[evaluator])
File "D:\miniconda3\envs\LY\lib\site-packages\torch4keras\model.py", line 230, in fit
self.output, self.loss, self.loss_detail = self.train_step(self.train_X, self.train_y)
File "D:\miniconda3\envs\LY\lib\site-packages\torch4keras\model.py", line 106, in train_step
loss_detail = self.criterion(output, train_y)
File "D:\miniconda3\envs\LY\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\LY\RE\test.py", line 163, in forward
loss = super().forward(y_pred, y_true.long())
File "D:\miniconda3\envs\LY\lib\site-packages\bert4torch\losses.py", line 96, in forward
y_pos_2 = torch.gather(y_pred, dim=-1, index=y_true) # [..., num_positive]
RuntimeError: index -1 is out of bounds for dimension 2 with size 1025
Process finished with exit code 1