MQF2DistributionLoss#
- class pytorch_forecasting.metrics.distributions.MQF2DistributionLoss(prediction_length: int, quantiles: List[float] | None = None, hidden_size: int | None = 4, es_num_samples: int = 50, beta: float = 1.0, icnn_hidden_size: int = 20, icnn_num_layers: int = 2, estimate_logdet: bool = False)[来源]#
基础:
DistributionLoss
基于文章的多变量分位数损失 Multivariate Quantile Function Forecaster。
需要安装额外的库:
pip install pytorch-forecasting[mqf2]
- Parameters:
prediction_length (int) – 最大预测长度。
分位数 (列表[浮点数], 可选) – 默认输出的分位数。 默认为 [0.02, 0.1, 0.25, 0.5, 0.75, 0.9, 0.98]。
hidden_size (int, 可选) - 每个预测长度的隐藏大小。默认值为 4。
es_num_samples (int, 可选) – 计算能量分数的样本数量。 如果为 None,则最大似然用于优化而不是能量分数。 默认为 50。
beta (float, 可选) – 在0和1.0之间,用于控制尺度敏感指标的灵敏度 (1=完全敏感)。默认为1.0。
icnn_hidden_size (int, 可选) – 分布估计网络的隐藏层大小。默认为20。
icnn_num_layers (int, optional) – 分布估计网络中的隐藏层数量。默认为2。
estimate_logdet (bool, optional) – 是否估计对数行列式。默认为 False。
方法
loss
(预测值, 实际值)计算负似然
将参数的张量映射到概率分布。
rescale_parameters
(parameters, target_scale, ...)将归一化参数缩放到输出所需的尺度。
to_quantiles
(y_pred[, quantiles])将网络预测转换为分位数预测。
- loss(y_pred: Tensor, y_actual: Tensor) Tensor [来源]#
计算负似然
- Parameters:
y_pred – 网络输出
y_actual – 实际值
- Returns:
可以应用反向传播的度量值
- Return type:
torch.Tensor
- map_x_to_distribution(x: Tensor) Distribution [来源]#
将参数的张量映射到概率分布。
- Parameters:
x (torch.Tensor) – 概率分布的参数。最后一个维度将索引这些参数
- Returns:
- 在此定义的torch概率分布
类属性
distribution_class
- Return type:
分布.Distribution
- rescale_parameters(parameters: Tensor, target_scale: Tensor, encoder: 基础估计器) Tensor [来源]#
将归一化参数缩放到输出所需的尺度。
- Parameters:
参数 (torch.Tensor) – 规范化参数(按最后一个维度索引)
target_scale (torch.Tensor) – 参数的规模 (n_batch_samples x (中心, 缩放))
encoder (BaseEstimator) – 原始编码器,最初对目标进行了标准化
- Returns:
真实/未标准化空间中的参数
- Return type:
torch.Tensor