gluonts.torch.model.simple_feedforward.estimator 模块#

class gluonts.torch.model.simple_feedforward.estimator.SimpleFeedForwardEstimator(prediction_length: int, context_length: Optional[int] = None, hidden_dimensions: Optional[List[int]] = None, lr: float = 0.001, weight_decay: float = 1e-08, distr_output: gluonts.torch.distributions.output.Output = gluonts.torch.distributions.studentT.StudentTOutput(beta=0.0), batch_norm: bool = False, batch_size: int =32, num_batches_per_epoch: int =50, trainer_kwargs: Optional[Dict[str, Any]] =None, train_sampler: Optional[gluonts.transform.sampler.InstanceSampler] =None, validation_sampler: Optional[gluonts.transform.sampler.InstanceSampler] =None)[source]#

基类:gluonts.torch.model.estimator.PyTorchLightningEstimator

用于训练前馈模型进行预测的估计器。

此类使用 SimpleFeedForwardModel 中定义的模型,并将其封装在 SimpleFeedForwardLightningModule 中进行训练:训练使用 PyTorch Lightning 的 pl.Trainer 类执行。

参数
  • prediction_length (int) – 预测范围的长度。

  • context_length – 模型在预测时间之前作为输入的时间步长数量(默认值:10 * prediction_length)。

  • hidden_dimensions – 前馈网络中隐藏层的大小(默认值:[20, 20])。

  • lr – 学习率(默认值:1e-3)。

  • weight_decay – 权重衰减正则化参数(默认值:1e-8)。

  • distr_output – 用于评估观测值和采样预测的分布(默认值:StudentTOutput())。

  • batch_norm – 是否应用批量归一化。

  • batch_size – 用于训练的批量大小(默认值:32)。

  • num_batches_per_epoch

    每个训练周期(epoch)要处理的批量数量

    (默认值:50)。

  • trainer_kwargs – 构造 pl.Trainer 时提供的额外参数。

  • train_sampler – 控制训练期间窗口的采样。

  • validation_sampler – 控制验证期间窗口的采样。

create_lightning_module() lightning.pytorch.core.module.LightningModule[source]#

创建并返回用于训练的网络(即计算损失)。

返回

根据输入数据计算损失的网络。

返回类型

pl.LightningModule

create_predictor(transformation: gluonts.transform._base.Transformation, module) gluonts.torch.model.predictor.PyTorchPredictor[source]#

创建并返回预测器对象。

参数
  • transformation – 应用于数据在进入模型之前的转换。

  • module – 训练好的 pl.LightningModule 对象。

返回

封装用于推理的 nn.Module 的预测器。

返回类型

预测器

create_training_data_loader(data: gluonts.dataset.Dataset, module: gluonts.torch.model.simple_feedforward.lightning_module.SimpleFeedForwardLightningModule, shuffle_buffer_length: Optional[int] = None, **kwargs) Iterable[source]#

为训练目的创建数据加载器。

参数
  • data – 用于创建数据加载器的数据集。

  • module – 将接收数据加载器批次的 pl.LightningModule 对象。

返回

数据加载器,即数据批次的迭代器。

返回类型

Iterable

create_transformation() gluonts.transform._base.Transformation[source]#

创建并返回训练和推理所需的转换。

返回

在训练和推理时按条目应用于数据集的转换。

返回类型

Transformation

create_validation_data_loader(data: gluonts.dataset.Dataset, module: gluonts.torch.model.simple_feedforward.lightning_module.SimpleFeedForwardLightningModule, **kwargs) Iterable[source]#

为验证目的创建数据加载器。

参数
  • data – 用于创建数据加载器的数据集。

  • module – 将接收数据加载器批次的 pl.LightningModule 对象。

返回

数据加载器,即数据批次的迭代器。

返回类型

Iterable

lead_time: int#
prediction_length: int#