X=torch.normal(mean=1,std=2,size=(3,4))
print(X)
tensor([[-0.1116, -3.4674, -0.0363, 1.5493],
[-0.7199, -0.7217, 2.8007, 1.1526],
[ 0.0578, 2.5465, 1.5857, 0.8619]])
torch.normal()函数:返回一个张量;是从一个给定mean(均值),std(方差)的正态分布中抽取随机数。mean和std都是属于张量类型的;
- 参数:
mean:均值;
std:标准差;
out:输出张量;文章来源:https://www.toymoban.com/news/detail-604125.html
size:张量的大小;文章来源地址https://www.toymoban.com/news/detail-604125.html
- 源码参数:
@overload
def normal(mean: Tensor, std: Tensor, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None) -> Tensor: ...
@overload
def normal(mean: Tensor, std: _float=1, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None) -> Tensor: ...
@overload
def normal(mean: _float, std: Tensor, *, generator: Optional[Generator]=None, out: Optional[Tensor]=None) -> Tensor: ...
@overload
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: ...
到了这里,关于torch.normal()函数的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!