當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python PyTorch HalfCauchy用法及代碼示例

本文簡要介紹python語言中 torch.distributions.half_cauchy.HalfCauchy 的用法。

用法:

class torch.distributions.half_cauchy.HalfCauchy(scale, validate_args=None)

參數

scale(float或者Tensor) -全柯西分布的尺度

基礎:torch.distributions.transformed_distribution.TransformedDistribution

創建由 scale 參數化的 half-Cauchy 分布,其中:

X ~ Cauchy(0, scale)
Y = |X| ~ HalfCauchy(scale)

例子:

>>> m = HalfCauchy(torch.tensor([1.0]))
>>> m.sample()  # half-cauchy distributed with scale=1
tensor([ 2.3214])

相關用法


注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.distributions.half_cauchy.HalfCauchy。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。