gluonts.torch.model.estimator module

class gluonts.torch.model.estimator.PyTorchLightningEstimator(trainer_kwargs: Dict[str, Any], lead_time: int = 0)[source]

Bases: gluonts.model.estimator.Estimator

An Estimator type with utilities for creating PyTorch-Lightning-based models.

To extend this class, one needs to implement three methods: create_transformation, create_training_network, create_predictor, create_training_data_loader, and create_validation_data_loader.

create_lightning_module() → pytorch_lightning.core.lightning.LightningModule[source]

Create and return the network used for training (i.e., computing the loss).

Returns

The network that computes the loss given input data.

Return type

nn.Module

create_predictor(transformation: gluonts.transform._base.Transformation, network: torch.nn.modules.module.Module) → gluonts.torch.model.predictor.PyTorchPredictor[source]

Create and return a predictor object.

Returns

A predictor wrapping a nn.Module used for inference.

Return type

Predictor

create_training_data_loader(data: gluonts.dataset.common.Dataset, network: torch.nn.modules.module.Module, **kwargs) → Iterable[source]
create_transformation() → gluonts.transform._base.Transformation[source]

Create and return the transformation needed for training and inference.

Returns

The transformation that will be applied entry-wise to datasets, at training and inference time.

Return type

Transformation

create_validation_data_loader(data: gluonts.dataset.common.Dataset, network: torch.nn.modules.module.Module, **kwargs) → Iterable[source]
freq = None
lead_time = None
prediction_length = None
train(training_data: gluonts.dataset.common.Dataset, validation_data: Optional[gluonts.dataset.common.Dataset] = None, num_workers: int = 0, shuffle_buffer_length: Optional[int] = None, cache_data: bool = False, **kwargs) → gluonts.torch.model.predictor.PyTorchPredictor[source]

Train the estimator on the given data.

Parameters
  • training_data – Dataset to train the model on.

  • validation_data – Dataset to validate the model on during training.

Returns

The predictor containing the trained model.

Return type

Predictor

train_model(training_data: gluonts.dataset.common.Dataset, validation_data: Optional[gluonts.dataset.common.Dataset] = None, num_workers: int = 0, shuffle_buffer_length: Optional[int] = None, cache_data: bool = False, **kwargs) → gluonts.torch.model.estimator.TrainOutput[source]
class gluonts.torch.model.estimator.TrainOutput(transformation, trained_net, trainer, predictor)[source]

Bases: tuple

property predictor

Alias for field number 3

property trained_net

Alias for field number 1

property trainer

Alias for field number 2

property transformation

Alias for field number 0