Pytorch中randn和rand函數的用法
- randn
torch.randn(*sizes, out=None) → Tensor
返回一個包含了從標准正態分布中抽取的一組隨機數的張量
size:張量的形狀,
out:結果張量。(目前還沒有看到使用這個參數的例子)
- rand也差不多其實:
torch.rand(*sizes, out=None) → Tensor
但是它是[0,1)之間的均勻分布
- 其他一些分布
離散正態分布
torch.normal(means, std, out=None) → → Tensor
線性間距向量
torch.linspace(start, end, steps=100, out=None) → Tensor
reference: