首页 > 其他 > 详细

pytorch的linspace, rand, randn, normal

时间:2020-02-22 14:38:26      阅读:61      评论:0      收藏:0      [点我收藏+]

torch.linspace

torch.linspace(start, end, steps) returns a one-dimensional tensor of equally spaced points between [start, end]。steps默认值是100。

技术分享图片

torch.rand

 torch.rand(size) returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1).

技术分享图片

torch.randn

torch.randn(size) returns a tensor filled with random numbers from a normal distribution with mean `0` and variance `1` (also called the standard normal distribution).

技术分享图片

torch.normal

torch.normal returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given.

The arguments `mean` is a tensor with the mean of each output element‘s normal distribution.

The arguments `std` is a tensor with the standard deviation of each output element‘s normal distribution.

torch.normal的参数给定方法有很多种:

第一种:给定mean (Tensor)和std (Tensor)

技术分享图片

 第二种:给定mean(float)和std (Tensor)

技术分享图片

第三种:给定mean (Tensor)和std (float),std也可不给,若不给定,则默认为1.0

技术分享图片

 第四种:给定mean (float)、std (float)和size(int...)

技术分享图片

 参考文献:PyTorch帮助文档

pytorch的linspace, rand, randn, normal

原文:https://www.cnblogs.com/picassooo/p/12344992.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!