我正在使用BERT模型来完成命名实体识别任务。我有torch版本- 1.2.0+cu9.2 torch vision版本-兼容cuda 9.2的0.4.0+cu9.2 Nvidia驱动程序
当我尝试使用以下命令训练模型时
loss, scores = model(b_input_ids.type(torch.cuda.LongTensor), token_type_ids=None,attention_mask=b_input_mask.to(device), labels=b_labels.type(torch.cuda.LongTensor))我得到了下面的错误-
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [35,0,0], thread: [0,0,0] Assertion `srcIndex < srcSelectDimSize` failed.有人能帮我解决这个问题吗?
发布于 2020-10-01 23:42:18
通过谷歌搜索,following hint给出了以下建议:
这是由于嵌入矩阵中的索引越界造成的。如果您在使用nn.Embedding层时看到此错误,则可以添加一个print语句,该语句显示每个输入的最小值和最大值。某些批处理可能具有越界索引。一旦你找到了错误的批处理,你应该看看它是如何创建的,这样你就可以修复这个错误。
如果不看你的代码,没有人会有更多的帮助。
https://stackoverflow.com/questions/64156127
复制相似问题