当前位置:   article > 正文

torch.normal()函数_torch.normal函数

torch.normal函数
  1. X=torch.normal(mean=1,std=2,size=(3,4))
  2. print(X)
  1. tensor([[-0.1116, -3.4674, -0.0363, 1.5493],
  2. [-0.7199, -0.7217, 2.8007, 1.1526],
  3. [ 0.0578, 2.5465, 1.5857, 0.8619]])

torch.normal()函数:返回一个张量;是从一个给定mean(均值),std(方差)的正态分布中抽取随机数。mean和std都是属于张量类型的;

  • 参数:

mean:均值;

std:标准差

out:输出张量;

size:张量的大小;

  • 源码参数:
  1. @overload
  2. def normal(mean: Tensor, std: Tensor, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None) -> Tensor: ...
  3. @overload
  4. def normal(mean: Tensor, std: _float=1, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None) -> Tensor: ...
  5. @overload
  6. def normal(mean: _float, std: Tensor, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None) -> Tensor: ...
  7. @overload
  8. def normal(mean: _float, std: _float, size: _size, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None, dtype: Optional[_dtype]=None, layout: Optional[_layout]=None, device: Optional[Union[_device, str, None]]=None, pin_memory: Optional[_bool]=False, requires_grad: Optional[_bool]=False) -> Tensor: ...
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/358177
推荐阅读
相关标签
  

闽ICP备14008679号