Back to models
Regressor

FCNRegressorTorch

Fully Convolutional Network (FCN) in PyTorch for time series regression.

Adapted from the TensorFlow FCN implementation in sktime.

Quickstart

python
from sktime.regression.deep_learning.fcn import FCNRegressorTorch

estimator = FCNRegressorTorch(filter_sizes: tuple=(128, 256, 128), kernel_sizes: tuple=(8, 5, 3), activation_hidden='relu', activation: str | None | Callable=None, init_weights: str | None='kaiming_uniform', num_epochs: int=2000, batch_size: int=16, optimizer: str | None | Callable='Adam', optimizer_kwargs: dict | None=None, criterion: str | None | Callable='MSELoss', criterion_kwargs: dict | None=None, callbacks: None | str | tuple [str, ... ]='ReduceLROnPlateau', callback_kwargs: dict | None=None, lr: float=0.01, verbose: bool=False, random_state: int=0)

Parameters(16)

filter_sizestuple of int, default = (128, 256, 128)
Number of filters for each convolutional layer. The number of convolutional layers is inferred from the length of this tuple.
kernel_sizestuple of int, default = (8, 5, 3)

Kernel size for each convolutional layer. Must have the same length as filter_sizes.

activation_hiddenstr or None or an instance of activation functions defined in

torch.nn, default = “relu” Activation function applied after each BatchNorm layer in the convolutional blocks. If str, supported values are "relu", "tanh", "sigmoid". If not str, must be an instantiated torch.nn.Module activation. If None, no activation is applied (identity).

activationstr or None or an instance of activation functions defined in
torch.nn, default = None Activation function used in the fully connected output layer.
init_weightsstr or None, default = “kaiming_uniform”

The method to initialize the weights of the convolutional layers. Supported values: "kaiming_uniform", "kaiming_normal", "xavier_uniform", "xavier_normal", or None for default PyTorch initialization.

num_epochsint, default = 2000
The number of epochs to train the model.
batch_sizeint, default = 16
The size of each mini-batch during training.
optimizercase insensitive str or None or an instance of optimizers

defined in torch.optim, default = “Adam” The optimizer to use for training the model. List of available optimizers: https://pytorch.org/docs/stable/optim.html#algorithms

optimizer_kwargsdict or None, default = None
Additional keyword arguments to pass to the optimizer.
criterioncase insensitive str or None or an instance of a loss function

defined in PyTorch, default = “MSELoss” The loss function to be used in training the neural network. List of available loss functions: https://pytorch.org/docs/stable/nn.html#loss-functions

criterion_kwargsdict or None, default = None
Additional keyword arguments to pass to the loss function.
callbacksNone or str or a tuple of str, default = “ReduceLROnPlateau”

Currently only learning rate schedulers are supported as callbacks. If more than one scheduler is passed, they are applied sequentially in the order they are passed. If None, then no learning rate scheduler is used. List of available learning rate schedulers: https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate

callback_kwargsdict or None, default = None
The keyword arguments to be passed to the callbacks.
lrfloat, default = 0.01
The learning rate to use for the optimizer.
verbosebool, default = False
Whether to print progress information during training.
random_stateint, default = 0
Seed to ensure reproducibility.

Examples

>>> from sktime.regression.deep_learning.fcn import FCNRegressorTorch
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test (split = "train")
>>> X_test, y_test = load_unit_test (split = "test")
>>> reg = FCNRegressorTorch (num_epochs = 20, batch_size = 4)
>>> reg. fit (X_train, y_train) FCNRegressorTorch(
... )