Professional Documents
Culture Documents
1. torch.rand:-
Returns a tensor filled with random numbers from a uniform distribution on the
interval [0, 1)
>>> torch.rand(4)
tensor([ 0.5204, 0.2503, 0.3525, 0.5673])
>>> torch.rand(2, 3)
tensor([[ 0.8237, 0.5781, 0.6879],
[ 0.3816, 0.7249, 0.0998]])
2. torch.rand_like:-
Returns a tensor with the same size as input that is filled with random numbers from
a uniform distribution on the interval [0, 1). torch.rand_like(input) is equivalent
to torch.rand(input.size(), dtype=input.dtype, layout=input.layout, device=inpu
t.device)
3. torch.randint:-