当前位置:网站首页>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]])
边栏推荐
- Goodbye to the cumbersome Excel, mastering data analysis and processing technology depends on it
- C语言的文件操作(一)
- torch.normal函数用法
- 【MQ我可以讲一个小时】
- Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
- Paginate the list collection and display the data on the page
- 数据库学习笔记
- 【LeetCode-SQL每日一练】——2. 第二高的薪水
- 面试官:生成订单30分钟未支付,则自动取消,该怎么实现?
- mysql存储过程
猜你喜欢
Mysql application cannot find my.ini file after installation
matlab abel变换图片处理
剑指offer基础版 ---- 第26天
Unity resources management series: Unity framework how to resource management
运用flask框架发送短信验证码的流程及具体代码
【JS面试题】面试官:“[1,2,3].map(parseInt)“ 输出结果是什么?答上来就算你通过面试
MySQL优化之慢日志查询
Redis Advanced - Cache Issues: Consistency, Penetration, Penetration, Avalanche, Pollution, etc.
Redis进阶 - 缓存问题:一致性、穿击、穿透、雪崩、污染等.
剑指offer专项突击版 --- 第 4 天
随机推荐
docker安装postgresSQL和设置自定义数据目录
面试官,不要再问我三次握手和四次挥手
What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
剑指offer专项突击版 ---- 第 6 天
STM32——DMA
剑指offer基础版 ----- 第25天
On-line monitoring system for urban waterlogging and water accumulation in bridges and tunnels
MySQL优化:从十几秒优化到三百毫秒
数据库学习笔记
Go中间件
剑指offer基础版 ---- 第27天
C语言教程(三)-if和循环
Centos7 install mysql5.7 steps (graphical version)
[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade
C语言教程(二)-printf及c自带的数据类型
Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
The interviewer asked me TCP three handshake and four wave, I really
110 MySQL interview questions and answers (continuously updated)
sql statement - how to query data in another table based on the data in one table
Input length must be multiple of 8 when decrypting with padded cipher