当前位置:网站首页>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]])
边栏推荐
- What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
- MySQL window function
- 分布式事务处理方案大 PK!
- STM32——DMA
- torch.normal函数用法
- centos7安装mysql5.7
- mysql5.7.35安装配置教程【超级详细安装教程】
- 基于web3.0使用钱包Metamask的三方登陆
- 运用flask框架发送短信验证码的流程及具体代码
- Unity resources management series: Unity framework how to resource management
猜你喜欢
快速掌握并发编程 --- 基础篇
剑指offer基础版 ---- 第29天
MySQL优化之慢日志查询
MySQL (updating)
[Introduction to MySQL 8 to Mastery] Basics - silent installation of MySQL on Linux system, cross-version upgrade
MySQL-Explain详解
Distributed transaction processing solution big PK!
Distributed Transactions - Introduction to Distributed Transactions, Distributed Transaction Framework Seata (AT Mode, Tcc Mode, Tcc Vs AT), Distributed Transactions - MQ
docker安装postgresSQL和设置自定义数据目录
Quickly master concurrent programming --- the basics
随机推荐
目标检测学习笔记
精解四大集合框架:List 核心知识总结
ABC D - Distinct Trio (Number of k-tuples
[MQ I can speak for an hour]
12 reasons for MySQL slow query
为什么要用Flink,怎么入门使用Flink?
Simple read operation of EasyExcel
MySQL8.0安装教程,在Linux环境安装MySQL8.0教程,最新教程 超详细
What are the advantages and disadvantages of Unity shader forge and the built-in shader graph?
剑指offer专项突击版 ---- 第2天
Paginate the list collection and display the data on the page
Lock wait timeout exceeded解决方案
TOGAF之架构标准规范(一)
Flink sink redis 写入Redis
Numpy中np.meshgrid的简单用法示例
Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
pycharm专业版使用
Unity resources management series: Unity framework how to resource management
C语言教程(二)-printf及c自带的数据类型
Pytorch教程Introduction中的神经网络实现示例