在训练github上源码时遇到了这一问题
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
但由于这一步报错代码在计算loss
loss = np.sum([criterion(torch.clamp(restored[j],0,1),target) for j in range(len(restored))])
有效解决方法是降低numpy的版本,原始版本1.21.4 降至 1.18.0