I was watching a tutorial on PyTorch and coding along and got stuck on function torch.randint
According to the documentation:
torch.randint(low=0, high, size, \*, generator=None, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
here, size is :
size (tuple) – a tuple defining the shape of the output tensor.
The YouTuber wrote
random_idx = torch.randint(0, len(train_data), size=[1]).item()
But [1] is not a tuple, it is a list. How is this possible?
I also tested it with a tuple and it worked just fine and every usage of randint() i found on the internet provides a tuple for size. E.g. size = (1,2) or size = (1,1).
I searched the source code for torch.randint but could not find it. I searched GitHub, PyTorch docs and even tried to find it in a local PyTorch library.