def create_predictor( self, transformation: transform.Transformation, trained_network: Seq2SeqTrainingNetwork, ) -> Predictor: # todo: this is specific to quantile output quantile_strs = [ Quantile.from_float(quantile).name for quantile in self.quantiles ] prediction_network = Seq2SeqPredictionNetwork( embedder=trained_network.embedder, scaler=trained_network.scaler, encoder=trained_network.encoder, enc2dec=trained_network.enc2dec, decoder=trained_network.decoder, quantile_output=trained_network.quantile_output, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, forecast_generator=QuantileForecastGenerator(quantile_strs), )
def create_predictor( self, transformation: Transformation, trained_network: HybridBlock ) -> Predictor: prediction_network = TransformerPredictionNetwork( encoder=self.encoder, decoder=self.decoder, history_length=self.history_length, context_length=self.context_length, prediction_length=self.prediction_length, distr_output=self.distr_output, cardinality=self.cardinality, embedding_dimension=self.embedding_dimension, lags_seq=self.lags_seq, scaling=True, num_parallel_samples=self.num_parallel_samples, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, )
def create_predictor(self, transformation: Transformation, trained_network: HybridBlock) -> Predictor: prediction_network = GPVARPredictionNetwork( target_dim=self.target_dim, target_dim_sample=self.target_dim, num_parallel_samples=self.num_parallel_samples, num_layers=self.num_layers, num_cells=self.num_cells, cell_type=self.cell_type, history_length=self.history_length, context_length=self.context_length, prediction_length=self.prediction_length, dropout_rate=self.dropout_rate, lags_seq=self.lags_seq, scaling=self.scaling, distr_output=self.distr_output, conditioning_length=self.conditioning_length, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, output_transform=self.output_transform, )
def create_predictor( self, transformation: Transformation, trained_network: HybridBlock) -> RepresentableBlockPredictor: prediction_network = SelfAttentionPredictionNetwork( context_length=self.context_length, prediction_length=self.prediction_length, d_hidden=self.model_dim, m_ffn=self.ffn_dim_multiplier, n_head=self.num_heads, n_layers=self.num_layers, n_output=self.num_outputs, cardinalities=self.cardinalities, kernel_sizes=self.kernel_sizes, dist_enc=self.distance_encoding, pre_ln=self.pre_layer_norm, dropout=self.dropout, temperature=self.temperature, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, forecast_generator=QuantileForecastGenerator( quantiles=[str(q) for q in prediction_network.quantiles], ), )
def create_predictor( self, transformation: transform.Transformation, trained_network: mx.gluon.HybridBlock, bin_values: np.ndarray, ) -> Predictor: prediction_network = WaveNetSampler( num_samples=self.num_parallel_samples, temperature=self.temperature, **self._get_wavenet_args(bin_values), ) # The lookup layer is specific to the sampling network here # we make sure it is initialized. prediction_network.initialize() copy_parameters( net_source=trained_network, net_dest=prediction_network, allow_missing=True, ) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, )
def create_predictor(self, transformation: Transformation, trained_network: HybridBlock) -> Predictor: prediction_network = LSTNetPredict( num_series=self.num_series, channels=self.channels, kernel_size=self.kernel_size, rnn_cell_type=self.rnn_cell_type, rnn_num_layers=self.rnn_num_layers, skip_rnn_cell_type=self.skip_rnn_cell_type, skip_rnn_num_layers=self.skip_rnn_num_layers, skip_size=self.skip_size, ar_window=self.ar_window, context_length=self.context_length, lead_time=self.lead_time, prediction_length=self.prediction_length, dropout_rate=self.dropout_rate, output_activation=self.output_activation, scaling=self.scaling, dtype=self.dtype, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, lead_time=self.lead_time, ctx=self.trainer.ctx, dtype=self.dtype, )
def create_predictor( self, transformation: Transformation, trained_network: HybridBlock ) -> Predictor: prediction_network = DeepStatePredictionNetwork( num_sample_paths=self.num_sample_paths, num_layers=self.num_layers, num_cells=self.num_cells, cell_type=self.cell_type, past_length=self.past_length, prediction_length=self.prediction_length, issm=self.issm, dropout_rate=self.dropout_rate, cardinality=self.cardinality, embedding_dimension=self.embedding_dimension, scaling=self.scaling, params=trained_network.collect_params(), ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, )
def create_predictor( self, transformation: Transformation, trained_network: ForkingSeq2SeqTrainingNetwork, ) -> Predictor: # todo: this is specific to quantile output quantile_strs = [ parse_quantile_input(q)[1] for q in self.quantile_output.quantiles ] prediction_network = ForkingSeq2SeqPredictionNetwork( encoder=trained_network.encoder, enc2dec=trained_network.enc2dec, decoder=trained_network.decoder, quantile_output=trained_network.quantile_output, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, forecast_cls_name=QuantileForecast.__name__, forecast_kwargs=dict(forecast_keys=quantile_strs), )
def create_predictor(self, transformation: Transformation, trained_network: HybridBlock) -> Predictor: prediction_network = DeepARPredictionNetwork( num_parallel_samples=self.num_parallel_samples, num_layers=self.num_layers, num_cells=self.num_cells, cell_type=self.cell_type, history_length=self.history_length, context_length=self.context_length, prediction_length=self.prediction_length, distr_output=self.distr_output, dropoutcell_type=self.dropoutcell_type, dropout_rate=self.dropout_rate, cardinality=self.cardinality, embedding_dimension=self.embedding_dimension, lags_seq=self.lags_seq, scaling=self.scaling, dtype=self.dtype, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, dtype=self.dtype, )
def create_predictor(self, transformation: Transformation, trained_network: HybridBlock) -> Predictor: prediction_network = GaussianProcessPredictionNetwork( prediction_length=self.prediction_length, context_length=self.context_length, cardinality=self.cardinality, num_samples=self.num_eval_samples, params=trained_network.collect_params(), kernel_output=self.kernel_output, params_scaling=self.params_scaling, ctx=self.trainer.ctx, float_type=self.float_type, max_iter_jitter=self.max_iter_jitter, jitter_method=self.jitter_method, sample_noise=self.sample_noise, ) copy_parameters(net_source=trained_network, net_dest=prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, float_type=self.float_type, )
def create_predictor( self, transformation: transform.Transformation, trained_network: mx.gluon.HybridBlock, bin_values: np.ndarray, ) -> Predictor: prediction_network = WaveNetSampler( num_samples=self.num_eval_samples, temperature=self.temperature, **self._get_wavenet_args(bin_values), ) # copy_parameters(net_source=trained_network, net_dest=prediction_network, ignore_extra=True) copy_parameters(net_source=trained_network, net_dest=prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, )
def create_predictor( self, transformation: Transformation, trained_network: HybridBlock) -> RepresentableBlockPredictor: prediction_network = TemporalFusionTransformerPredictionNetwork( context_length=self.context_length, prediction_length=self.prediction_length, d_var=self.variable_dim, d_hidden=self.hidden_dim, n_head=self.num_heads, n_output=self.num_outputs, d_past_feat_dynamic_real=list( self.past_dynamic_feature_dims.values()), c_past_feat_dynamic_cat=list( self.past_dynamic_cardinalities.values()), d_feat_dynamic_real=[1] * len(self.time_features) + list(self.dynamic_feature_dims.values()), c_feat_dynamic_cat=list(self.dynamic_cardinalities.values()), d_feat_static_real=list(self.static_feature_dims.values()), c_feat_static_cat=list(self.static_cardinalities.values()), dropout=self.dropout_rate, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, forecast_generator=QuantileForecastGenerator( quantiles=[str(q) for q in prediction_network.quantiles], ), )
def create_predictor( self, transformation: Transformation, trained_network: ForkingSeq2SeqNetworkBase, ) -> Predictor: # this is specific to quantile output quantile_strs = [ Quantile.from_float(quantile).name for quantile in self.quantile_output.quantiles ] prediction_network = ForkingSeq2SeqPredictionNetwork( encoder=trained_network.encoder, enc2dec=trained_network.enc2dec, decoder=trained_network.decoder, quantile_output=trained_network.quantile_output, context_length=self.context_length, cardinality=self.cardinality, embedding_dimension=self.embedding_dimension, scaling=self.scaling, dtype=self.dtype, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, forecast_generator=QuantileForecastGenerator(quantile_strs), )
def create_predictor(self, transformation: Transformation, trained_network: HybridBlock) -> Predictor: prediction_network = MyPredNetwork1( prediction_length=self.prediction_length, num_cells=self.num_cells) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx)
def create_predictor( self, transformation: Transformation, trained_network: ForkingSeq2SeqNetworkBase, ) -> Predictor: quantile_strs = ( [ Quantile.from_float(quantile).name for quantile in self.quantile_output.quantiles ] if self.quantile_output is not None else None ) prediction_network_class = ( ForkingSeq2SeqPredictionNetwork if self.quantile_output is not None else ForkingSeq2SeqDistributionPredictionNetwork ) prediction_network = prediction_network_class( encoder=trained_network.encoder, enc2dec=trained_network.enc2dec, decoder=trained_network.decoder, quantile_output=trained_network.quantile_output, distr_output=trained_network.distr_output, context_length=self.context_length, num_forking=self.num_forking, cardinality=self.cardinality, embedding_dimension=self.embedding_dimension, scaling=self.scaling, dtype=self.dtype, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, forecast_generator=( QuantileForecastGenerator(quantile_strs) if quantile_strs is not None else DistributionForecastGenerator(self.distr_output) ), )
def create_predictor(self, transformation: Transformation, trained_network: HybridBlock) -> Predictor: prediction_network = CustomSimpleFeedForwardPredNetwork( prediction_length=self.prediction_length, distr_output=self.distr_output, distr_output_type=self.distr_output_type, num_cells=self.num_cells, num_sample_paths=self.num_sample_paths, alpha=self.alpha) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, )
def create_predictor( self, transformation: Transformation, trained_network: gluon.HybridBlock, ) -> Predictor: prediction_network = MyPredNetwork( prediction_length=self.prediction_length, cells=self.cells, act_type=self.act_type, ) copy_parameters(trained_network, prediction_network) return RepresentableBlockPredictor( input_transform=transformation, prediction_net=prediction_network, batch_size=self.trainer.batch_size, freq=self.freq, prediction_length=self.prediction_length, ctx=self.trainer.ctx, )