当前位置:网站首页>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]])边栏推荐
- Why use Flink and how to get started with Flink?
- 面试官问我TCP三次握手和四次挥手,我真的是
- Shell重油常压塔模拟仿真与控制
- Linux系统安装mysql(rpm方式安装)
- Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
- MySQL window function
- 2022-07-30:以下go语言代码输出什么?A:[]byte{} []byte;B:[]byte{} []uint8;C:[]uint8{} []byte;D:[]uin8{} []uint8。
- Temporal客户端模型
- 剑指offer专项突击版 ---- 第 6 天
- 12 reasons for MySQL slow query
猜你喜欢

【LeetCode-SQL每日一练】——2. 第二高的薪水

CentOS7 - yum install mysql

MySQL事务(transaction) (有这篇就足够了..)

Anaconda配置环境指令
![[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade](/img/af/7a2cdcc6535c04c508c9ddf9ee0cb2.png)
[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade

剑指offer专项突击版 ---- 第 6 天

Unity mobile game performance optimization series: performance tuning for the CPU side

1. 获取数据-requests.get()

MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细

Centos7 install mysql5.7
随机推荐
SQL injection of DVWA
MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细
C语言的文件操作(一)
mysql5.7.35安装配置教程【超级详细安装教程】
剑指offer专项突击版 ---- 第 6 天
STM32 - DMA
CentOS7 —— yum安装mysql
Temporal对比Cadence
Unity mobile game performance optimization series: performance tuning for the CPU side
Distributed transaction processing solution big PK!
面试官竟然问我怎么分库分表?幸亏我总结了一套八股文
Temporal线上部署
MySQL8.0.26安装配置教程(windows 64位)
Flink sink redis 写入Redis
What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
mysql uses on duplicate key update to update data in batches
【MQ我可以讲一个小时】
SQL行列转换
centos7安装mysql5.7
快速掌握并发编程 --- 基础篇