torchts package¶
Submodules¶
Base classes¶
- class torchts.nn.model.TimeSeriesModel(optimizer, optimizer_args=None, criterion=<function mse_loss>, criterion_args=None, scheduler=None, scheduler_args=None, scaler=None)[source]¶
Bases:
pytorch_lightning.core.lightning.LightningModule
Base class for all TorchTS models.
- Parameters
optimizer (torch.optim.Optimizer) – Optimizer
opimizer_args (dict) – Arguments for the optimizer
criterion – Loss function
criterion_args (dict) – Arguments for the loss function
scheduler (torch.optim.lr_scheduler) – Learning rate scheduler
scheduler_args (dict) – Arguments for the scheduler
scaler (torchts.utils.scaler.Scaler) – Scaler
- fit(x, y, max_epochs=10, batch_size=128)[source]¶
Fits model to the given data.
- Parameters
x (torch.Tensor) – Input data
y (torch.Tensor) – Output data
max_epochs (int) – Number of training epochs
batch_size (int) – Batch size for torch.utils.data.DataLoader
- abstract forward(x, y=None, batches_seen=None)[source]¶
Forward pass.
- Parameters
x (torch.Tensor) – Input data
- Returns
torch.Tensor – Predicted data
- predict(x)[source]¶
Runs model inference.
- Parameters
x (torch.Tensor) – Input data
- Returns
torch.Tensor – Predicted data
- test_step(batch, batch_idx)[source]¶
Tests model for one step.
- Parameters
batch (torch.Tensor) – Output of the torch.utils.data.DataLoader
batch_idx (int) – Integer displaying index of this batch
- training_step(batch, batch_idx)[source]¶
Trains model for one step.
- Parameters
batch (torch.Tensor) – Output of the torch.utils.data.DataLoader
batch_idx (int) – Integer displaying index of this batch
- validation_step(batch, batch_idx)[source]¶
Validates model for one step.
- Parameters
batch (torch.Tensor) – Output of the torch.utils.data.DataLoader
batch_idx (int) – Integer displaying index of this batch