gluonts.mx.model.predictor module#
- class gluonts.mx.model.predictor.GluonPredictor(input_names: typing.List[str], prediction_net, batch_size: int, prediction_length: int, ctx: mxnet.context.Context, input_transform: gluonts.transform._base.Transformation, lead_time: int = 0, forecast_generator: gluonts.model.forecast_generator.ForecastGenerator = gluonts.model.forecast_generator.SampleForecastGenerator(), output_transform: typing.Optional[typing.Callable[[typing.Dict[str, typing.Any], numpy.ndarray], numpy.ndarray]] = None, dtype: typing.Type = <class 'numpy.float32'>)[source]#
Bases:
gluonts.model.predictor.Predictor
Base predictor type for Gluon-based models.
- Parameters
input_names – Input tensor names for the graph
prediction_net – Network that will be called for prediction
batch_size – Number of time series to predict in a single batch
prediction_length – Number of time steps to predict
input_transform – Input transformation pipeline
output_transform – Output transformation
ctx – MXNet context to use for computation
forecast_generator – Class to generate forecasts from network outputs
- BlockType#
alias of
mxnet.gluon.block.Block
- as_symbol_block_predictor(batch: Optional[Dict[str, Any]] = None, dataset: Optional[gluonts.dataset.Dataset] = None) gluonts.mx.model.predictor.SymbolBlockPredictor [source]#
Returns a variant of the current
GluonPredictor
backed by a Gluon SymbolBlock. If the current predictor is already aSymbolBlockPredictor
, it just returns itself.One of batch or datset must be set.
- Parameters
batch – A batch of data to use for the required forward pass after the hybridize() call of the underlying network.
dataset – Dataset from which a batch is extracted if batch is not set.
- Returns
A predictor derived from the current one backed by a SymbolBlock.
- Return type
- hybridize(batch: Dict[str, Any]) None [source]#
Hybridizes the underlying prediction network.
- Parameters
batch – A batch of data to use for the required forward pass after the hybridize() call.
- property network#
- predict(dataset: gluonts.dataset.Dataset, num_samples: Optional[int] = None, num_workers: Optional[int] = None, num_prefetch: Optional[int] = None, **kwargs) Iterator[gluonts.model.forecast.Forecast] [source]#
Compute forecasts for the time series in the provided dataset. This method is not implemented in this abstract class; please use one of the subclasses. :param dataset: The dataset containing the time series to predict.
- Returns
Iterator over the forecasts, in the same order as the dataset iterable was provided.
- Return type
Iterator[Forecast]
- class gluonts.mx.model.predictor.RepresentableBlockPredictor(prediction_net, batch_size: int, prediction_length: int, ctx: mxnet.context.Context, input_transform: gluonts.transform._base.Transformation, lead_time: int = 0, forecast_generator: gluonts.model.forecast_generator.ForecastGenerator = gluonts.model.forecast_generator.SampleForecastGenerator(), output_transform: typing.Optional[typing.Callable[[typing.Dict[str, typing.Any], numpy.ndarray], numpy.ndarray]] = None, dtype: typing.Type = <class 'numpy.float32'>)[source]#
Bases:
gluonts.mx.model.predictor.GluonPredictor
A predictor which serializes the network structure using the JSON- serialization methods located in gluonts.core.serde. Use the following logic to create a RepresentableBlockPredictor from a trained prediction network.
>>> def create_representable_block_predictor( ... prediction_network: mx.gluon.HybridBlock, ... **kwargs ... ) -> RepresentableBlockPredictor: ... return RepresentableBlockPredictor( ... prediction_net=prediction_network, ... **kwargs ... )
- BlockType#
alias of
mxnet.gluon.block.HybridBlock
- as_symbol_block_predictor(batch: Optional[Dict[str, Any]] = None, dataset: Optional[gluonts.dataset.Dataset] = None) gluonts.mx.model.predictor.SymbolBlockPredictor [source]#
Returns a variant of the current
GluonPredictor
backed by a Gluon SymbolBlock. If the current predictor is already aSymbolBlockPredictor
, it just returns itself.One of batch or datset must be set.
- Parameters
batch – A batch of data to use for the required forward pass after the hybridize() call of the underlying network.
dataset – Dataset from which a batch is extracted if batch is not set.
- Returns
A predictor derived from the current one backed by a SymbolBlock.
- Return type
- classmethod deserialize(path: pathlib.Path, ctx: Optional[mxnet.context.Context] = None) gluonts.mx.model.predictor.RepresentableBlockPredictor [source]#
Load a serialized predictor from the given path.
- Parameters
path – Path to the serialized files predictor.
**kwargs – Optional context/device parameter to be used with the predictor. If nothing is passed will use the GPU if available and CPU otherwise.
- class gluonts.mx.model.predictor.SymbolBlockPredictor(input_names: typing.List[str], prediction_net, batch_size: int, prediction_length: int, ctx: mxnet.context.Context, input_transform: gluonts.transform._base.Transformation, lead_time: int = 0, forecast_generator: gluonts.model.forecast_generator.ForecastGenerator = gluonts.model.forecast_generator.SampleForecastGenerator(), output_transform: typing.Optional[typing.Callable[[typing.Dict[str, typing.Any], numpy.ndarray], numpy.ndarray]] = None, dtype: typing.Type = <class 'numpy.float32'>)[source]#
Bases:
gluonts.mx.model.predictor.GluonPredictor
A predictor which serializes the network structure as an MXNet symbolic graph. Should be used for models deployed in production in order to ensure forward-compatibility as GluonTS models evolve.
Used by the training shell if training is invoked with a hyperparameter use_symbol_block_predictor = True.
- BlockType#
alias of
mxnet.gluon.block.SymbolBlock
- as_symbol_block_predictor(batch: Optional[Dict[str, Any]] = None, dataset: Optional[gluonts.dataset.Dataset] = None) gluonts.mx.model.predictor.SymbolBlockPredictor [source]#
Returns a variant of the current
GluonPredictor
backed by a Gluon SymbolBlock. If the current predictor is already aSymbolBlockPredictor
, it just returns itself.One of batch or datset must be set.
- Parameters
batch – A batch of data to use for the required forward pass after the hybridize() call of the underlying network.
dataset – Dataset from which a batch is extracted if batch is not set.
- Returns
A predictor derived from the current one backed by a SymbolBlock.
- Return type
- classmethod deserialize(path: pathlib.Path, ctx: Optional[mxnet.context.Context] = None) gluonts.mx.model.predictor.SymbolBlockPredictor [source]#
Load a serialized predictor from the given path.
- Parameters
path – Path to the serialized files predictor.
**kwargs – Optional context/device parameter to be used with the predictor. If nothing is passed will use the GPU if available and CPU otherwise.