当前位置:网站首页>torch.normal function usage
torch.normal function usage
2022-07-31 05:32:00 【Cheng-O】
Usage given by official documentation:
torch.normal(means, std, out=None)
means the mean range and shape of the given tensor, std gives the standard deviation of each mean
Official example:
torch.normal(means=torch.arange(1, 11), std=torch.arange(1, 0, -0.1))1.51041.69552.48954.91854.98956.91557.36838.18368.71649.8916[torch.FloatTensor of size 10]Actual situation:
>>> torch.normal(means=torch.arange(1, 11), std=torch.arange(1, 0, -0.1))Traceback (most recent call last):File "", line 1, in TypeError: normal() received an invalid combination of arguments - got (means=Tensor, std=Tensor, ), but expected one of:* (Tensor mean, Tensor std, *, torch.Generator generator, Tensor out)* (Tensor mean, float std, *, torch.Generator generator, Tensor out)* (float mean, Tensor std, *, torch.Generator generator, Tensor out)* (float mean, float std, tuple of ints size, *, torch.Generator generator, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad) From the error type, it can be seen that means is no longer used in torch but mean is used, that is, only a normal distribution with a fixed mean can be generated.
The correct way to open:
Use the fourth option:
torch.normal(mean, std, size)
The three parameters are mean, standard deviation and size
>>> torch.normal(3, 0.1, (3, 4))tensor([[2.9425, 3.1877, 2.9735, 3.0982],[3.0061, 2.9918, 2.7953, 3.0066],[2.8219, 2.9578, 2.8813, 2.9014]])Use the third option:
torch.normal(mean, stds)
The two parameters are: mean and standard deviation, the standard deviation is used to determine the range size
>>> torch.normal(3, torch.ones(3, 4)/10)tensor([[2.8491, 3.0263, 3.0888, 3.0818],[3.1101, 2.7490, 3.1847, 3.0861],[2.8530, 2.8666, 2.9634, 3.1875]])边栏推荐
- SQL injection of DVWA
- Linux系统安装mysql(rpm方式安装)
- Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
- Three oj questions on leetcode
- 限流的原理
- 面试官问我TCP三次握手和四次挥手,我真的是
- 数据集划分以及交叉验证法
- Why use Flink and how to get started with Flink?
- datagrip带参sql查询
- The interviewer asked me how to divide the database and the table?Fortunately, I summed up a set of eight-part essays
猜你喜欢

Simple read operation of EasyExcel

sql statement - how to query data in another table based on the data in one table

12个MySQL慢查询的原因分析

剑指offer基础版 ---- 第26天

Multiple table query of sql statement

With MVC, why DDD?
![[mysql improves query efficiency] Mysql database query is slow to solve the problem](/img/fa/502a2efdd37508f15541558851a254.png)
[mysql improves query efficiency] Mysql database query is slow to solve the problem

剑指offer基础版 ---- 第29天

Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?

Minesweeper game (written in c language)
随机推荐
<urlopen error [Errno 11001] getaddrinfo failed>的解决、isinstance()函数初略介绍
剑指offer基础版 ----- 第25天
剑指offer专项突击版 --- 第 4 天
剑指offer基础版 ----第31天
On-line monitoring system for urban waterlogging and water accumulation in bridges and tunnels
剑指offer基础版 ----- 第28天
What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
matlab abel变换图片处理
Minesweeper game (written in c language)
Multiple table query of sql statement
剑指offer专项突击版 ---- 第2天
Flink sink ES 写入 ES(带密码)
剑指offer基础版--- 第23天
MySQL window function
Sql解析转换之JSqlParse完整介绍
运用flask框架发送短信验证码的流程及具体代码
The monitoring of Doris study notes
精解四大集合框架:List 核心知识总结
数据集划分以及交叉验证法
[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade