torch.rand()
参考:https://pytorch.org/docs/stable/torch.html#torch.rand
*torch.rand(size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
返回在区间[0,1)[0,1)上由均匀分布的随机数填充的张量
张量的形状由可变参数大小来定义。
example
>>> 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]])
torch.rand_like()
参考:https://pytorch.org/docs/stable/torch.html#torch.rand_like
torch.rand_like(input, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) → Tensor
返回与输入相同大小的张量&#x