训练一个ocr模型的时候torch版本升级导致:
The size of tensor a (0) must match the size of tensor b (37) at non-singleton dimension 2
问题出现在loss.backward()
部分,后来阅读相关代码发现在计算loss的时候需要关闭cudnn:
torch.backends.cudnn.enabled = False
loss = criterion(preds, text, preds_size, length)
torch.backends.cudnn.enabled = True
网友评论