- torch.normal(mean, std, out=None)
- 功能:生成正态分布(高斯分布)
- mean: 均值
- std: 标准差
- 四种模式:
- mean为标量,std为标量
- mean为标量,std为张量
- mean为张量,std为标量
- mean为张量,std为张量
torch.normal(0,1,size=(1,5)) tensor([[ 0.5548, 0.1402, 0.5849, 1.2391, -0.2564]]) torch.normal(0,std=torch.arange(1, 0, -0.1)) tensor([-0.6172, -0.1014, 0.0054, -0.0847, 0.2791, -0.0295, -0.1140, -0.3000, -0.2172, 0.0075]) torch.normal(mean=torch.arange(1., 11.),std = 10) tensor([ 0.0548, 33.3666, 6.6326, -3.3032, 16.0448, 18.3752, -12.6373, -0.1594, 16.0896, 12.4073]) torch.normal(mean=torch.arange(1., 11.), std=torch.arange(1, 0, -0.1)) tensor([-0.1131, 2.1779, 2.9984, 3.9909, 4.2449, 6.1312, 6.7345, 7.6574, 8.8338, 10.1323])
通过torch.normal创建四种模式的正态分布张量
最新推荐文章于 2025-02-04 12:40:08 发布