paddlets.models.forecasting.dl.paddle_base
- class PaddleBaseModel(in_chunk_len: int, out_chunk_len: int, skip_chunk_len: int = 0)[source]
Bases:
BaseModelBase class for all paddle deep learning models.
- Parameters
in_chunk_len (int) – The size of the loopback window, i.e., the number of time steps feed to the model.
out_chunk_len (int) – The size of the forecasting horizon, i.e., the number of time steps output by the model.
skip_chunk_len (int) – Optional, the number of time steps between in_chunk and out_chunk for a single sample. The skip chunk is neither used as a feature (i.e. X) nor a label (i.e. Y) for a single sample. By default, it will NOT skip any time steps.
- _network
A paddle.nn.Layer instance.
- Type
paddle.nn.Layer
- _optimizer
- Type
paddle.optimizer.Optimizer
- _callback_container
a container containing one or more callback instance(s).
- Type
paddlets.models.dl.paddlepaddle.callbacks.CallbackContainer
- abstract fit(train_data: Union[TSDataset, List[TSDataset]], valid_data: Optional[Union[TSDataset, List[TSDataset]]] = None)[source]
Fit a paddle deep learning model instance.
Any non-abstract classes inherited from this class should implement this method.
- abstract predict(data: TSDataset) TSDataset[source]
Make prediction.
Any non-abstract classes inherited from this class should implement this method.
- save(path: str, network_model: bool = False, dygraph_to_static=True, batch_size: Union[None, int] = None) None[source]
Saves a PaddleBaseModel instance to a disk file.
1> A PaddleBaseModel (or any child classes inherited from PaddleBaseModel) instance have a set of member variables, they can be divided into 3 categories: pickle-serializable members (e.g. python built-in type such as int, str, dict, etc.), paddle-related pickle-not-serializable members (e.g. paddle.nn.Layer, paddle.optimizer.Optimizer), paddle-not-related pickle-not-serializable members.
2> To call this method, self._network and self._optimizer must not be None.
- Parameters
path (str) – A path string containing a model file name.
network_model (bool) – Save network model structure and parameters separately for Paddle Inference or not, default False.
dygraph_to_static (bool) – Change network from dygraph to static or not, it works when network_model==True, default True.
batch_size (int) – The fixed batch size for the param input_spec of network_model save, it works when network_model==True, default None.
- Raises
ValueError –
- static load(path: str) PaddleBaseModel[source]
Loads a PaddleBaseModel from a file.
As optimizer does not affect the model prediction results, currently optimizer will NOT be loaded.
- Parameters
path (str) – A path string containing a model file name.
- Returns
the loaded PaddleBaseModel instance.
- Return type