The question says it all. I want to get a 2-D torch.Tensor
with size [a,b]
filled with values from a uniform distribution (in range [r1,r2]
Utilize the torch.distributions
package to generate samples from different distributions.
For example to sample a 2d PyTorch tensor of size [a,b]
from a uniform distribution of range(low, high)
try the following sample code
import torch
a,b = 2,3 #dimension of the pytorch tensor to be generated
low,high = 0,1 #range of uniform distribution
x = torch.distributions.uniform.Uniform(low,high).sample([a,b])