The shape of the mask [10] at index 0 does not match the shape of the indexed tensor [200] at index
·


当运行上述代码后,出现错误The shape of the mask [10] at index 0 does not match the shape of the indexed tensor [200] at index 0。
原因:
在对 x 进行索引时,掩码 pred_neg 的形状与 x 的形状不匹配。具体来说,pred_neg 的长度为 10,但是我尝试使用它来索引 x,而 x 的长度为 200,因此出现了维度不匹配的错误。
解决方法:
扩展 pred_neg 的长度,使其与 x 的第一个维度相匹配。可以使用类似以下代码来扩展pred_neg 的长度:

更多推荐



所有评论(0)