pytorch RuntimeError: one of the variables needed for gradient computation has been modified by an i
发布时间
阅读量:
阅读量
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [25088, 512]], which is output 0 of TBackward, is at version 4; expected version 3 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
bash
模型架构包括一个主干网络,以及两个用于分类任务的全连接层,同时具备两个输入端口。
损失函数由两部分构成:一是两个输入对应的分类损失,二是主干网络输出特征之间的相似性损失。
潜在问题:在反向传播过程中出现错误,可能的原因在于相似性损失的计算与反向传播发生在分类损失之前,这可能破坏了计算图的完整性。
全部评论 (0)
还没有任何评论哟~
