方法:
torch.is_tensor(obj)
判断obj是否为一个tensor对象
x = torch.tensor([1, 2, 3])
y = [1, 2, 3]
torch.is_tensor(x)
True
torch.is_tensor(y)
False
方法:
torch.is_tensor(obj)
判断obj是否为一个tensor对象
x = torch.tensor([1, 2, 3])
y = [1, 2, 3]
torch.is_tensor(x)
True
torch.is_tensor(y)
False