Difference between 'torch.Tensor()' and 'torch.tensor()'?

Anyone can tell me the difference between torch.Tensor and torch.tensor?How to choose which one to use?Thanks!

I would recommend to use torch.tensor to initialize your tensor with values, as e.g. the dtype will be inferred automatically, while torch.Tensor uses torch.float32 by default as far as I know.

Thanks your reply!Do you know the difference about their?Thanks!

I think torch.Tensor is the legacy abstraction.
Have a look at these docs for info how to properly create tensors now.

1 Like