当前位置:网站首页>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]])
边栏推荐
- MySQL transaction isolation level, rounding
- 12 reasons for MySQL slow query
- Quickly master concurrent programming --- the basics
- 关于LocalDateTime的全局返回时间带“T“的时间格式处理
- 剑指offer专项突击版 ---- 第 6 天
- MySQL事务(transaction) (有这篇就足够了..)
- pycharm专业版使用
- Workflow番外篇
- tf.keras.utils.pad_sequences()
- Minio upload file ssl certificate is not trusted
猜你喜欢
随机推荐
mysql uses on duplicate key update to update data in batches
Moment Pool Cloud quickly installs packages such as torch-sparse and torch-geometric
三次握手与四次挥手
Anaconda配置环境指令
Flink sink redis 写入Redis
Apache DButils使用注意事项--with modifiers “public“
Three oj questions on leetcode
【MQ我可以讲一个小时】
[Detailed explanation of ORACLE Explain]
C语言教程(三)-if和循环
Lock wait timeout exceeded解决方案
Distributed transaction processing solution big PK!
Temporal客户端模型
docker安装postgresSQL和设置自定义数据目录
centos7安装mysql5.7步骤(图解版)
Information System Project Manager Core Test Site (55) Configuration Manager (CMO) Work
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
2022-07-30:以下go语言代码输出什么?A:[]byte{} []byte;B:[]byte{} []uint8;C:[]uint8{} []byte;D:[]uin8{} []uint8。
工作流编排引擎-Temporal
MySQL-Explain详解