Q:

Is this the way to create a PyTorch scalar?

I'm new to PyTorch, and just wanted to kindly confirm if the following creates scalars with values, 1, 2, and 3, respectively?
import torch

a = torch.tensor(1)
b = torch.tensor(2)
c = torch.tensor(3)

Thanks.

A:

From the example in the documentation for torch.tensor:
>>> torch.tensor(3.14159)  # Create a scalar (zero-dimensional tensor)
tensor(3.1416)

Therefore, it appears they endorse that passing a number creates the corresponding scalar.

