一、问题 NameError: name 'Tensor' is not defined 二、解决方法 把 import torch torch.Tensor() 改为 from torch import Tensor Tensor()