当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python PyTorch HalfNormal用法及代码示例


本文简要介绍python语言中 torch.distributions.half_normal.HalfNormal 的用法。

用法:

class torch.distributions.half_normal.HalfNormal(scale, validate_args=None)

参数

scale(float或者Tensor) -完全正态分布的尺度

基础:torch.distributions.transformed_distribution.TransformedDistribution

创建由 scale 参数化的半正态分布,其中:

X ~ Normal(0, scale)
Y = |X| ~ HalfNormal(scale)

例子:

>>> m = HalfNormal(torch.tensor([1.0]))
>>> m.sample()  # half-normal distributed with scale=1
tensor([ 0.1046])

相关用法


注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.distributions.half_normal.HalfNormal。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。