torch.randn 方法

网友投稿 935 2022-05-29

torch.randn 方法

torch.randn 方法

返回一个张量,其中包含来自均值为0、方差为1的正态分布的随机数(也称为标准正态分布)

官方文档

https://pytorch.org/docs/stable/generated/torch.randn.html

Example:

>>> torch.randn(4) tensor([-2.1436, 0.9966, 2.3426, -0.6366]) >>> torch.randn(2, 3) tensor([[ 1.5954, 2.8929, -1.0923], [ 1.1719, -0.4709, -0.1996]])

1

2

3

4

5

自己测试的一个实例:

self.img_ch = 3 self.img_size = 256 input = torch.randn([1, self.img_ch, self.img_size, self.img_size]).to(self.device) print('input size:') print(input.size()) print(input)

1

2

3

4

5

6

7

8

9

10

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:新手学Python之学习官网教程(四: More Control Flow Tools)
下一篇:Navicat查看数据所有表属性和ER关系图
相关文章