torch.normal()函数

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:输出张量;

size:张量的大小;

  • 源码参数:
@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: ...

你可能感兴趣的:(深度学习,深度学习,python,人工智能)