gluonts.mx.model.wavenet package#
- class gluonts.mx.model.wavenet.WaveNet(bin_values: List[float], n_residue: int, n_skip: int, dilation_depth: int, n_stacks: int, act_type: str, cardinality: List[int], embedding_dimension: int, pred_length: int, **kwargs)[source]#
Bases:
mxnet.gluon.block.HybridBlock
- base_net(F, inputs, one_step_prediction=False, queues=None)[source]#
Forward pass through the network.
- Parameters
F –
inputs – Inputs to the network: (batch_size, n_residue, sequence_length)
one_step_prediction – Flag indicating whether the network is “unrolled/propagated” one step at a time (prediction phase).
queues – Convolutional queues containing past computations. Should be provided if one_step_prediction is True.
- Returns
Tuple – A tensor containing the unnormalized outputs of the network. Shape: (batch_size, pred_length, num_bins). A list containing the convolutional queues for each layer. The queue corresponding to layer l has shape: (batch_size, n_residue, 2^l).
- Return type
(Tensor, List)
- get_full_features(F, feat_static_cat: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], past_observed_values: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], past_time_feat: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], future_time_feat: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], future_observed_values: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#
Prepares the inputs for the network by repeating static feature and concatenating it with time features and observed value indicator.
- Parameters
F –
feat_static_cat – Static categorical features: (batch_size, num_cat_features)
past_observed_values – Observed value indicator for the past target: (batch_size, receptive_field)
past_time_feat – Past time features: (batch_size, num_time_features, receptive_field)
future_time_feat – Future time features: (batch_size, num_time_features, pred_length)
future_observed_values – Observed value indicator for the future target: (batch_size, pred_length). This will be set to all ones, if not provided (e.g., during prediction).
scale – scale of the time series: (batch_size, 1)
- Returns
A tensor containing all the features ready to be passed through the network. Shape: (batch_size, num_features, receptive_field + pred_length)
- Return type
Tensor
- static get_receptive_field(dilation_depth, n_stacks)[source]#
Return the length of the receptive field.
- target_feature_embedding(F, target, features)[source]#
Provides a joint embedding for the target and features.
- Parameters
F –
target ((batch_size, sequence_length)) –
features ((batch_size, num_features, sequence_length)) –
- Returns
A tensor containing a joint embedding of target and features. Shape: (batch_size, n_residue, sequence_length)
- Return type
Tensor
- class gluonts.mx.model.wavenet.WaveNetEstimator(freq: str, prediction_length: int, trainer: gluonts.mx.trainer._base.Trainer = gluonts.mx.trainer._base.Trainer(add_default_callbacks=True, callbacks=None, clip_gradient=10.0, ctx=None, epochs=200, hybridize=False, init='xavier', learning_rate=0.01, num_batches_per_epoch=50, weight_decay=1e-08), cardinality: List[int] = [1], seasonality: Optional[int] = None, embedding_dimension: int = 5, num_bins: int = 1024, hybridize_prediction_net: bool = False, n_residue=24, n_skip=32, dilation_depth: Optional[int] = None, n_stacks: int = 1, train_window_length: Optional[int] = None, temperature: float = 1.0, act_type: str = 'elu', num_parallel_samples: int = 200, train_sampler: Optional[gluonts.transform.sampler.InstanceSampler] = None, validation_sampler: Optional[gluonts.transform.sampler.InstanceSampler] = None, batch_size: int = 32, negative_data: bool = False)[source]#
Bases:
gluonts.mx.model.estimator.GluonEstimator
Model with Wavenet architecture and quantized target.
- Parameters
freq – Frequency of the data to train on and predict
prediction_length (int) – Length of the prediction horizon
trainer – Trainer object to be used (default: Trainer())
cardinality – Number of values of the each categorical feature (default: [1])
embedding_dimension – Dimension of the embeddings for categorical features (the same dimension is used for all embeddings, default: 5)
num_bins – Number of bins used for quantization of signal (default: 1024)
hybridize_prediction_net – Boolean (default: False)
n_residue – Number of residual channels in wavenet architecture (default: 24)
n_skip – Number of skip channels in wavenet architecture (default: 32)
dilation_depth – Number of dilation layers in wavenet architecture. If set to None (default), dialation_depth is set such that the receptive length is at least as long as typical seasonality for the frequency and at least 2 * prediction_length.
n_stacks – Number of dilation stacks in wavenet architecture (default: 1)
temperature – Temparature used for sampling from softmax distribution. For temperature = 1.0 (default) sampling is according to estimated probability.
act_type – Activation type used after before output layer (default: “elu”). Can be any of ‘elu’, ‘relu’, ‘sigmoid’, ‘tanh’, ‘softrelu’, ‘softsign’.
num_parallel_samples – Number of evaluation samples per time series to increase parallelism during inference. This is a model optimization that does not affect the accuracy (default: 200)
train_sampler – Controls the sampling of windows during training.
validation_sampler – Controls the sampling of windows during validation.
batch_size – The size of the batches to be used training and prediction.
- create_predictor(transformation: gluonts.transform._base.Transformation, trained_network: mxnet.gluon.block.HybridBlock) gluonts.model.predictor.Predictor [source]#
Create and return a predictor object.
- Parameters
transformation – Transformation to be applied to data before it goes into the model.
module – A trained HybridBlock object.
- Returns
A predictor wrapping a HybridBlock used for inference.
- Return type
- create_training_data_loader(data: gluonts.dataset.Dataset, **kwargs) Iterable[Dict[str, Any]] [source]#
Create a data loader for training purposes.
- Parameters
data – Dataset from which to create the data loader.
- Returns
The data loader, i.e. and iterable over batches of data.
- Return type
DataLoader
- create_training_network() gluonts.mx.model.wavenet._network.WaveNetTraining [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
HybridBlock
- 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
- create_validation_data_loader(data: gluonts.dataset.Dataset, **kwargs) Iterable[Dict[str, Any]] [source]#
Create a data loader for validation purposes.
- Parameters
data – Dataset from which to create the data loader.
- Returns
The data loader, i.e. and iterable over batches of data.
- Return type
DataLoader
- lead_time: int#
- prediction_length: int#
- class gluonts.mx.model.wavenet.WaveNetSampler(bin_values: List[float], num_samples: int, temperature: float = 1.0, **kwargs)[source]#
Bases:
gluonts.mx.model.wavenet._network.WaveNet
Runs Wavenet generation in an auto-regressive manner using caching for speedup [PKC+16].
Same arguments as WaveNet. In addition
- Parameters
pred_length – Length of the prediction horizon
num_samples – Number of sample paths to generate in parallel in the graph
temperature – If set to 1.0 (default), sample according to estimated probabilities, if set to 0.0 most likely sample at each step is chosen.
post_transform – An optional post transform that will be applied to the samples
- get_initial_conv_queues(F, past_target, features)[source]#
Build convolutional queues saving intermediate computations.
- Parameters
F –
past_target ((batch_size, receptive_field)) –
features ((batch_size, num_features, receptive_field)) –
- Returns
A list containing the convolutional queues for each layer. The queue corresponding to layer l has shape: (batch_size, n_residue, 2^l).
- Return type
List
- hybrid_forward(F, feat_static_cat: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], past_target: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], past_observed_values: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], past_time_feat: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], future_time_feat: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol] [source]#
Computes the training loss for the wavenet model.
- Parameters
F –
feat_static_cat – Static categorical features: (batch_size, num_cat_features)
past_target – Past target: (batch_size, receptive_field)
past_observed_values – Observed value indicator for the past target: (batch_size, receptive_field)
past_time_feat – Past time features: (batch_size, num_time_features, receptive_field)
future_time_feat – Future time features: (batch_size, num_time_features, pred_length)
scale – scale of the time series: (batch_size, 1)
- Returns
Prediction samples with shape (batch_size, num_samples, pred_length)
- Return type
Tensor