错误:
在pytorch中,做 backward 时,出现错误:
"RuntimeError: one of the variables needed for gradient computation has been modified by an inplace"
解决:
#把下面两行改成第三行
#mask = pos_cos > self.cos_thr
#pos_cos[mask] = pos_cos_m[mask]
pos_cos = torch.where(pos_cos > self.cos_thr, pos_cos_m, pos_cos)