有时候总会有userwarning,虽然不是报错不影响程序运行,但是看着烦
UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
解决方案:
在代码开头:
import warnings
warnings.filterwarnings('ignore')