torch.randn 方法
【摘要】
torch.randn 方法
返回一个张量,其中包含来自均值为0、方差为1的正态分布的随机数(也称为标准正态分布)
官方文档
https://pytorch.org/docs/stable/...
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
文章来源: positive.blog.csdn.net,作者:墨理学AI,版权归原作者所有,如需转载,请联系作者。
原文链接:positive.blog.csdn.net/article/details/113738840
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)