gluonts.torch.distributions 包#
- class gluonts.torch.distributions.AffineTransformed(base_distribution: torch.distributions.distribution.Distribution, loc=None, scale=None)[源码]#
基类:
torch.distributions.transformed_distribution.TransformedDistribution
表示仿射变换后的随机变量的分布。
这是
Y = scale * X + loc
的分布,其中X
是根据base_distribution
分布的随机变量。- 参数
base_distribution – 原始分布
loc – 仿射变换的平移参数。
scale – 仿射变换的缩放参数。
- property mean#
返回分布的均值。
- property stddev#
返回分布的标准差。
- property variance#
返回分布的方差。
- class gluonts.torch.distributions.BetaOutput(beta: float = 0.0)[源码]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'concentration0': 1, 'concentration1': 1}#
- distr_cls#
别名:
torch.distributions.beta.Beta
- classmethod domain_map(concentration1: torch.Tensor, concentration0: torch.Tensor)[源码]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- property value_in_support: float#
一个浮点值,用于计算相应输出的损失是有效的。
默认为 0.0。
- class gluonts.torch.distributions.BinnedUniforms(bins_lower_bound: float, bins_upper_bound: float, logits: torch.Tensor, numb_bins: int = 100, validate_args: Optional[bool] = None)[源码]#
分箱均匀分布。
Bases:
torch.distributions.distribution.Distribution
- 参数
bins_lower_bound (float) – 分箱边缘的下限
bins_upper_bound (float) – 分箱边缘的上限
numb_bins (int) – 在 bins_lower_bound 和 bins_upper_bound 之间分配的等距分箱数量。默认值为 100。
logits (tensor) – 定义每个分箱概率的对数几率 (logits)。这些值经过 softmax 处理。张量形状为 (*batch_shape,)
validate_args (bool) –
- arg_constraints = {'logits': Real()}#
- property bins_prob#
返回观察点落在每个分箱中的概率 bins_prob.shape: (*batch_shape, event_shape)。event_shape 为 numb_bins
- expand(batch_shape, _instance=None)[源码]#
返回一个新的分布实例(或填充派生类提供的现有实例),其批处理维度扩展到 batch_shape。此方法在其分布参数上调用
expand
。因此,这不会为扩展的分布实例分配新的内存。此外,当首次创建实例时,这不会重复 __init__.py 中的任何参数检查或参数广播。- 参数
batch_shape (torch.Size) – 所需的扩展尺寸。
_instance – 需要覆盖 .expand 的子类提供的新实例。
- 返回
批处理维度扩展到 batch_size 的新分布实例。
- get_one_hot_bin_indicator(x, in_float=False)[源码]#
预计 x 的形状为 (*batch_shape),例如 ()、(32, ) 或 (32, 168, )
- has_rsample = False#
- icdf(quantiles)[源码]#
分位数张量 quantiles 的逆累积分布函数 (icdf)。‘quantiles’ 的形状为 (*batch_shape),取值范围为 (0.0, 1.0)
这是应从外部调用的函数。
- property log_bins_prob#
- support = Real()#
- class gluonts.torch.distributions.BinnedUniformsOutput(bins_lower_bound: float, bins_upper_bound: float, num_bins: int)[源码]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) gluonts.torch.distributions.binned_uniforms.BinnedUniforms [源码]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(logits: torch.Tensor) torch.Tensor [源码]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.DiscreteDistribution(values: torch.Tensor, probs: torch.Tensor, validate_args: Optional[bool] = None)[源码]#
分箱均匀分布。
实现离散分布,其中底层随机变量从有限集 values 中取值,并具有相应的概率。
注意: values 可以包含重复项,在这种情况下,重复项的概率质量会累加起来。
一个自然的损失函数,特别是考虑到新观察值不一定来自有限集 values,是排序概率得分 (RPS)。因此,为了与其它模型的术语保持一致,log_prob 实现为负 RPS。
- static adjust_probs(values_sorted, probs_sorted)[源码]#
将所有重复值的概率质量放入一个位置(重复项的最后一个索引)。
假设: values_sorted 已排序!
- 参数
values_sorted –
probs_sorted –
- 返回
- class gluonts.torch.distributions.DistributionOutput(beta: float = 0.0)[源码]#
基类:
gluonts.torch.distributions.output.Output
根据网络的输出构造分布的类。
- distr_cls: type#
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.distributions.distribution.Distribution [源码]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- domain_map(*args: torch.Tensor)[源码]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_dim: int#
事件维度数,即此对象构造的分布的 event_shape 元组的长度。
- property forecast_generator: gluonts.model.forecast_generator.ForecastGenerator#
- loss(target: torch.Tensor, distr_args: Tuple[torch.Tensor, ...], loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.Tensor [源码]#
根据网络输出计算目标数据的损失。
- 参数
target – 用于计算损失的目标时间序列的值。
distr_args – 可用于构造输出分布的参数。
loc – 分布的位置参数,可选。
scale – 分布的比例参数,可选。
- 返回
损失值,与目标形状相同。
- 返回类型
loss_values
- class gluonts.torch.distributions.GammaOutput(beta: float = 0.0)[源码]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'concentration': 1, 'rate': 1}#
- distr_cls#
别名:
torch.distributions.gamma.Gamma
- classmethod domain_map(concentration: torch.Tensor, rate: torch.Tensor)[源码]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- property value_in_support: float#
一个浮点值,用于计算相应输出的损失是有效的。
默认为 0.0。
- class gluonts.torch.distributions.GeneralizedPareto(xi, beta, validate_args=None)[源码]#
分箱均匀分布。
广义帕累托分布。
- arg_constraints = {'beta': GreaterThan(lower_bound=0.0), 'xi': GreaterThan(lower_bound=0.0)}#
- has_rsample = False#
- property stddev#
返回分布的标准差。
- support = GreaterThan(lower_bound=0.0)#
- class gluonts.torch.distributions.GeneralizedParetoOutput[源码]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) gluonts.torch.distributions.generalized_pareto.GeneralizedPareto [源码]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(xi: torch.Tensor, beta: torch.Tensor) Tuple[torch.Tensor, torch.Tensor] [源码]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.ISQF(spline_knots: torch.Tensor, spline_heights: torch.Tensor, beta_l: torch.Tensor, beta_r: torch.Tensor, qk_y: torch.Tensor, qk_x: torch.Tensor, tol: float = 0.0001, validate_args: bool = False)[源码]#
分箱均匀分布。
论文
Learning Quantile Functions without Quantile Crossing for Distribution-free Time Series Forecasting
中增量(样条)分位数函数的分布类,作者:Park, Robinson, Aubet, Kan, Gasthaus, Wang :param spline_knots: 参数化样条结点的 x 位置(y 位置)的张量形状: (*batch_shape, (num_qk-1), num_pieces)
- 参数
- property batch_shape: torch.Size#
返回参数进行批处理的形状。
- cdf(z: torch.Tensor) torch.Tensor [源码]#
计算分位数水平 alpha_tilde,使得 q(alpha_tilde) = z :param z: 形状为 (*batch_shape,) 的张量
- 返回
形状为 (*batch_shape,) 的张量
- 返回类型
alpha_tilde
- cdf_spline(z: torch.Tensor) torch.Tensor [源码]#
对于观测值 z 和在 [qk_x[k], qk_x[k+1]] 中定义的样条,计算分位数水平 alpha_tilde,使得 alpha_tilde。
= q^{-1}(z) 如果 z 在 qk_x[k] 和 qk_x[k+1] 之间 = qk_x[k] 如果 z<qk_x[k] = qk_x[k+1] 如果 z>qk_x[k+1] :param z: 观测值,形状 = (*batch_shape,)
- 返回
相应的分位数水平,形状 = (*batch_shape, num_qk-1)
- 返回类型
alpha_tilde
- cdf_tail(z: torch.Tensor, left_tail: bool = True) torch.Tensor [源码]#
计算分位数水平 alpha_tilde,使得 alpha_tilde。
= q^{-1}(z) 如果 z 在尾部区域 = qk_x_l 或 qk_x_r 如果 z 在非尾部区域 :param z: 观测值,形状 = (*batch_shape,) :param left_tail: 如果为 True,则计算左尾部的 alpha_tilde
否则,计算右尾部的 alpha_tilde
- 返回
对应的分位数水平,形状为 (*batch_shape,)
- 返回类型
alpha_tilde
- crps(z: torch.Tensor) torch.Tensor [source]#
计算 CRPS 的解析形式。:param z: 要评估的观测值。形状为 (*batch_shape,)
- 返回
包含 CRPS 的 Tensor,形状与 z 相同
- 返回类型
Tensor
- crps_spline(z: torch.Tensor) torch.Tensor [source]#
计算样条的 CRPS 解析形式。:param z: 要评估的观测值。形状为 (*batch_shape,)
- 返回
包含 CRPS 的 Tensor,形状与 z 相同
- 返回类型
Tensor
- crps_tail(z: torch.Tensor, left_tail: bool = True) torch.Tensor [source]#
计算左/右尾部的 CRPS 解析形式。:param z: 要评估的观测值。形状为 (*batch_shape,) :param left_tail: 如果为 True,则计算左尾部的 CRPS
否则,计算右尾部的 CRPS
- 返回
包含 CRPS 的 Tensor,形状与 z 相同
- 返回类型
Tensor
- static parameterize_qk(quantile_knots: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] [source]#
用于参数化 num_qk 分位数节点的 x 或 y 位置的函数。:param quantile_knots: 分位数节点的 x 或 y 位置
形状: (*batch_shape, num_qk)
- static parameterize_spline(spline_knots: torch.Tensor, qk: torch.Tensor, qk_plus: torch.Tensor, tol: float = 0.0001) Tuple[torch.Tensor, torch.Tensor] [source]#
用于参数化样条节点 x 或 y 位置的函数。:param spline_knots: 参数化样条节点位置的变量。:param qk: 分位数节点 (qk) 的 x 或 y 位置,
索引为 1, …, num_qk-1,形状: (*batch_shape, num_qk-1)
- static parameterize_tail(beta: torch.Tensor, qk_x: torch.Tensor, qk_y: torch.Tensor) Tuple[torch.Tensor, torch.Tensor] [source]#
用于参数化尾部参数的函数。注意指数尾部由 q(alpha) 给出
= a_l log(alpha) + b_l 如果是左尾部 = a_r log(1-alpha) + b_r 如果是右尾部 其中 a_l=1/beta_l, b_l=-a_l*log(qk_x_l)+q(qk_x_l) a_r=1/beta_r, b_r=a_r*log(1-qk_x_r)+q(qk_x_r) :param beta: 参数化左尾部或右尾部,形状: (*batch_shape,)
形状: (*batch_shape,)
- 参数
qk_y – 分位数节点最左侧或最右侧的 y 位置,形状: (*batch_shape,)
- 返回
tail_a – 如上所述的 a_l 或 a_r
tail_b – 如上所述的 b_l 或 b_r
- quantile_internal(alpha: torch.Tensor, dim: Optional[int] = None) torch.Tensor [source]#
在输入的分位数水平 input_alpha 上评估分位数函数。:param alpha: 形状为 (*batch_shape,) 的 Tensor(如果 axis=None),或包含
在指定位置有附加轴,否则
- 参数
dim – 包含要计算的不同分位数水平的轴的索引。详细信息请阅读下面的描述
- 返回
分位数 Tensor,形状与 alpha 相同
- 返回类型
Tensor
- class gluonts.torch.distributions.ISQFOutput(num_pieces: int, qk_x: List[float], tol: float = 0.0001)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
增量(样条)分位数函数的 DistributionOutput 类。:param num_pieces: 每个样条的样条片段数量
当 num_pieces = 1 时,ISQF 退化为 IQF
- 参数
qk_x – 包含分位数节点 x 位置的列表
tol – 用于数值保护的容差
- distr_cls#
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) gluonts.torch.distributions.isqf.ISQF [source]#
输出分布类的函数。distr_args: 分布参数。loc: 数据均值的偏移。scale: 数据缩放
- classmethod domain_map(spline_knots: torch.Tensor, spline_heights: torch.Tensor, beta_l: torch.Tensor, beta_r: torch.Tensor, quantile_knots: torch.Tensor, tol: float = 0.0001) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] [source]#
域映射函数。此函数的输入由 self.args_dim 指定。
spline_knots, spline_heights: 参数化样条节点的 x-/ y-位置,形状 = (*batch_shape, (num_qk-1)*num_pieces)
beta_l, beta_r: 参数化左/右尾部,形状 = (*batch_shape, 1)
quantile_knots: 参数化分位数节点 y-位置,形状 = (*batch_shape, num_qk)
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.ImplicitQuantileNetwork(outputs: torch.Tensor, taus: torch.Tensor, validate_args=None)[source]#
分箱均匀分布。
隐式分位数的分布类,可以从中采样或计算分位数损失。
- 参数
outputs – 隐式分位数网络的输出。
taus – 对应输出的 Beta 或 Uniform 分布的随机 Tensor。
- arg_constraints: Dict[str, torch.distributions.constraints.Constraint] = {}#
- class gluonts.torch.distributions.ImplicitQuantileNetworkOutput(output_domain: Optional[str] = None, concentration1: float = 1.0, concentration0: float = 1.0, cos_embedding_dim: int = 64)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
来自 Gouttes 等人 2021 年论文
Probabilistic Time Series Forecasting with Implicit Quantile Networks
(https://arxiv.org/abs/2107.03743) 的 IQN 的 DistributionOutput 类。- 参数
output_domain – 可选的输出域映射。可以是 “positive”、“unit” 或 None。
concentration1 – 在训练期间对 taus 进行采样时,Beta 分布的 Alpha 参数。
concentration0 – 在训练期间对 taus 进行采样时,Beta 分布的 Beta 参数。
cos_embedding_dim – IQN 的 taus 嵌入层的嵌入维度。默认为 64。
- args_dim: Dict[str, int] = {'quantile_function': 1}#
- distribution(distr_args, loc=0, scale=None) gluonts.torch.distributions.implicit_quantile_network.ImplicitQuantileNetwork [source]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(*args)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape#
与输出对象兼容的每个独立事件的形状。
- in_features: int#
- loss(target: torch.Tensor, distr_args: Tuple[torch.Tensor, ...], loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.Tensor [source]#
根据网络输出计算目标数据的损失。
- 参数
target – 用于计算损失的目标时间序列的值。
distr_args – 可用于构造输出分布的参数。
loc – 分布的位置参数,可选。
scale – 分布的比例参数,可选。
- 返回
损失值,与目标形状相同。
- 返回类型
loss_values
- class gluonts.torch.distributions.LaplaceOutput(beta: float = 0.0)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'loc': 1, 'scale': 1}#
- distr_cls#
的别名
torch.distributions.laplace.Laplace
- classmethod domain_map(loc: torch.Tensor, scale: torch.Tensor)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.NegativeBinomialOutput(beta: float = 0.0)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'logits': 1, 'total_count': 1}#
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.distributions.distribution.Distribution [source]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(total_count: torch.Tensor, logits: torch.Tensor)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.NormalOutput(beta: float = 0.0)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'loc': 1, 'scale': 1}#
- distr_cls#
的别名
torch.distributions.normal.Normal
- classmethod domain_map(loc: torch.Tensor, scale: torch.Tensor)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.Output[source]#
基类:
object
将原始神经网络输出转换为预测并计算损失。
- args_dim: Dict[str, int]#
- domain_map(*args: torch.Tensor) Tuple[torch.Tensor, ...] [source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property dtype#
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- property forecast_generator: gluonts.model.forecast_generator.ForecastGenerator#
- in_features: int#
- loss(target: torch.Tensor, distr_args: Tuple[torch.Tensor, ...], loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.Tensor [source]#
根据网络输出计算目标数据的损失。
- 参数
target – 用于计算损失的目标时间序列的值。
distr_args – 可用于构造输出分布的参数。
loc – 分布的位置参数,可选。
scale – 分布的比例参数,可选。
- 返回
损失值,与目标形状相同。
- 返回类型
loss_values
- property value_in_support: float#
一个浮点值,用于计算相应输出的损失是有效的。
默认为 0.0。
- class gluonts.torch.distributions.PiecewiseLinear(gamma: torch.Tensor, slopes: torch.Tensor, knot_spacings: torch.Tensor, validate_args=False)[source]#
分箱均匀分布。
- property batch_shape: torch.Size#
返回参数进行批处理的形状。
- class gluonts.torch.distributions.PiecewiseLinearOutput(num_pieces: int)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) gluonts.torch.distributions.piecewise_linear.PiecewiseLinear [source]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(gamma: torch.Tensor, slopes: torch.Tensor, knot_spacings: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor] [source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.PoissonOutput(beta: float = 0.0)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'rate': 1}#
- distr_cls#
的别名
torch.distributions.poisson.Poisson
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.distributions.distribution.Distribution [source]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(rate: torch.Tensor)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.QuantileOutput(quantiles: List[float])[source]#
基类:
gluonts.torch.distributions.output.Output
- args_dim: Dict[str, int]#
- domain_map(*args: torch.Tensor) Tuple[torch.Tensor, ...] [source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- property forecast_generator: gluonts.model.forecast_generator.ForecastGenerator#
- in_features: int#
- loss(target: torch.Tensor, distr_args: Tuple[torch.Tensor, ...], loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.Tensor [source]#
根据网络输出计算目标数据的损失。
- 参数
target – 用于计算损失的目标时间序列的值。
distr_args – 可用于构造输出分布的参数。
loc – 分布的位置参数,可选。
scale – 分布的比例参数,可选。
- 返回
损失值,与目标形状相同。
- 返回类型
loss_values
- property quantiles: List[float]#
- class gluonts.torch.distributions.SplicedBinnedPareto(bins_lower_bound: float, bins_upper_bound: float, logits: torch.Tensor, upper_gp_xi: torch.Tensor, upper_gp_beta: torch.Tensor, lower_gp_xi: torch.Tensor, lower_gp_beta: torch.Tensor, numb_bins: int = 100, tail_percentile_gen_pareto: float = 0.05, validate_args=None)[source]#
Bases:
gluonts.torch.distributions.binned_uniforms.BinnedUniforms
拼接分箱帕累托单变量分布。
- 参数
bins_lower_bound (分箱边缘的下界) –
bins_upper_bound (分箱边缘的上界) –
numb_bins (在 bins_lower_bound 和 bins_upper_bound 之间分配的等距分箱数量。默认值为 100。) –
tail_percentile_gen_pareto (分布的百分位数,表示每个尾部。默认值为 0.05。注意:此对称百分位数仍可表示不对称的上尾和下尾。) –
- arg_constraints = {'logits': Real(), 'lower_gp_beta': GreaterThan(lower_bound=0.0), 'lower_gp_xi': GreaterThan(lower_bound=0.0), 'upper_gp_beta': GreaterThan(lower_bound=0.0), 'upper_gp_xi': GreaterThan(lower_bound=0.0)}#
- has_rsample = False#
- log_prob(x: torch.Tensor, for_training=True)[source]#
- 参数
x (大小为 'batch_size', 1 的张量) –
for_training (布尔值,表示返回对数概率,或返回损失(即调整后的对数概率)。) –
- support = Real()#
- class gluonts.torch.distributions.SplicedBinnedParetoOutput(bins_lower_bound: float, bins_upper_bound: float, num_bins: int, tail_percentile_gen_pareto: float)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) gluonts.torch.distributions.binned_uniforms.BinnedUniforms [source]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(logits: torch.Tensor, upper_gp_xi: torch.Tensor, upper_gp_beta: torch.Tensor, lower_gp_xi: torch.Tensor, lower_gp_beta: torch.Tensor) Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor] [source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.StudentTOutput(beta: float = 0.0)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- args_dim: Dict[str, int] = {'df': 1, 'loc': 1, 'scale': 1}#
- distr_cls#
- classmethod domain_map(df: torch.Tensor, loc: torch.Tensor, scale: torch.Tensor)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
- class gluonts.torch.distributions.TruncatedNormal(loc: torch.Tensor, scale: torch.Tensor, min: Union[torch.Tensor, float] = - 1.0, max: Union[torch.Tensor, float] = 1.0, upscale: Union[torch.Tensor, float] = 5.0, tanh_loc: bool = False)[source]#
分箱均匀分布。
实现具有位置缩放的截断正态分布。
位置缩放防止位置“过远”地远离 0,这最终会导致数值不稳定的样本和不良的梯度计算(例如,梯度爆炸)。实际上,位置是根据以下公式计算的:
\[loc = tanh(loc / upscale) * upscale.\]可以通过关闭 tanh_loc 参数来禁用此行为(参见下文)。
- 参数
loc – 正态分布位置参数
scale – 正态分布 sigma 参数(方差的平方根)
min – 分布的最小值。默认值 = -1.0
max – 分布的最大值。默认值 = 1.0
upscale – 缩放因子。默认值 = 5.0
tanh_loc – 如果
True
,则使用上述公式进行位置缩放,否则保留原始值。默认值为False
参考文献
注意
- 此实现基于以下代码:
- arg_constraints = {'loc': Real(), 'scale': GreaterThan(lower_bound=1e-06)}#
- property entropy#
返回分布的熵,按 batch_shape 批量计算。
- 返回
形状为 batch_shape 的张量。
- eps = 1e-06#
- has_rsample = True#
- property mean#
返回分布的均值。
- rsample(sample_shape=None)[source]#
如果分布参数是批量的,则生成 sample_shape 形状的重参数化样本或 sample_shape 形状的重参数化样本批量。
- property support#
返回表示此分布支持的
Constraint
对象。
- property variance#
返回分布的方差。
- class gluonts.torch.distributions.TruncatedNormalOutput(min: float = - 1.0, max: float = 1.0, upscale: float = 5.0, tanh_loc: bool = False)[source]#
基类:
gluonts.torch.distributions.distribution_output.DistributionOutput
- distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) torch.distributions.distribution.Distribution [source]#
根据构造函数参数集合以及可选的比例张量,构造关联的分布。
- 参数
distr_args – 底层分布类型的构造函数参数。
loc – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
scale – 可选张量,形状与结果分布的 batch_shape+event_shape 相同。
- classmethod domain_map(loc: torch.Tensor, scale: torch.Tensor)[source]#
将参数转换为正确的形状和域。
域取决于分布的类型,而正确的形状是通过重塑尾部轴获得的,以便返回的张量定义了正确事件形状的分布。
- property event_shape: Tuple#
与输出对象兼容的每个独立事件的形状。
子模块#
- gluonts.torch.distributions.affine_transformed 模块
- gluonts.torch.distributions.binned_uniforms 模块
- gluonts.torch.distributions.discrete_distribution 模块
- gluonts.torch.distributions.distribution_output 模块
- gluonts.torch.distributions.generalized_pareto 模块
- gluonts.torch.distributions.implicit_quantile_network 模块
- gluonts.torch.distributions.isqf 模块
- gluonts.torch.distributions.negative_binomial 模块
- gluonts.torch.distributions.output 模块
- gluonts.torch.distributions.piecewise_linear 模块
- gluonts.torch.distributions.quantile_output 模块
- gluonts.torch.distributions.spliced_binned_pareto 模块
- gluonts.torch.distributions.studentT 模块
- gluonts.torch.distributions.truncated_normal 模块