码迷,mamicode.com
首页 > 其他好文 > 详细

pytorch的linspace, rand, randn, normal

时间:2020-02-22 14:16:13      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:图片   points   inf   alt   orm   nbsp   tor   number   png   

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

标签:图片   points   inf   alt   orm   nbsp   tor   number   png   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!