Hello, I’m very new in Pytorch, what is the difference between torch.rand(size=(3,4)) and torch.rand(3,4))
I don’t really understand the “size” means, I checked Docs but still not… please help, thanks.
There is no difference, since the first argument is the size
arg and the name can thus be skipped.
Both will return a tensor with the size [3, 4]
containing random values drawn from a uniform distribution in [0, 1)
:
torch.rand(size=(3,4))
# tensor([[0.7919, 0.7024, 0.1932, 0.8998],
# [0.5805, 0.9587, 0.5769, 0.1992],
# [0.5168, 0.5733, 0.6506, 0.5737]])
torch.rand(3,4)
# tensor([[0.9716, 0.0944, 0.5419, 0.0745],
# [0.8470, 0.7681, 0.2453, 0.4496],
# [0.2281, 0.8196, 0.1646, 0.8195]])
1 Like
Thank you so much!!!