隐式分位数网络分布损失#
- class pytorch_forecasting.metrics.distributions.ImplicitQuantileNetworkDistributionLoss(quantiles: List[float] | None = None, input_size: int | None = 16, hidden_size: int | None = 32, n_loss_samples: int | None = 64)[来源]#
基础:
DistributionLoss
隐式分位数网络分布损失。
基于 概率时间序列预测与隐式分位数网络。一个网络用于直接将网络输出映射到一个分位数。
- Parameters:
prediction_length (int) – 最大预测长度。
分位数 (列表[浮点数], 可选) – 默认输出的分位数。 默认为 [0.02, 0.1, 0.25, 0.5, 0.75, 0.9, 0.98]。
input_size (int, 可选) – 每个预测长度的输入大小。默认为16。
hidden_size (int, 可选) – 每个预测长度的隐藏大小。默认值为64。
n_loss_samples (int, 可选) – 用于计算损失的量化样本数量。
方法
loss
(预测值, 实际值)计算负似然
rescale_parameters
(parameters, target_scale, ...)将归一化参数缩放到输出所需的尺度。
sample
(y_pred, n_samples)从分布中抽样。
to_prediction
(y_pred[, n_samples])将网络预测转换为点预测。
to_quantiles
(y_pred[, quantiles])将网络预测转换为分位数预测。
- loss(y_pred: Tensor, y_actual: Tensor) Tensor [来源]#
计算负似然
- Parameters:
y_pred – 网络输出
y_actual – 实际值
- Returns:
可以应用反向传播的度量值
- Return type:
torch.Tensor
- 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
- sample(y_pred, n_samples: int) Tensor [来源]#
从分布中抽样。
- Parameters:
y_pred – 网络的预测输出 (形状 batch_size x n_timesteps x n_paramters)
n_samples (int) – 要抽取的样本数量
- Returns:
具有样本的张量(形状 为 batch_size x n_timesteps x n_samples)
- Return type:
torch.Tensor