Pytorch中randn和rand函數的用法


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:

https://blog.csdn.net/Hningning/article/details/102575272


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM