Back to models
Classifier

InceptionTimeClassifierTorch

InceptionTime Deep Learning Classifier in PyTorch.

Quickstart

python
from sktime.classification.deep_learning.inceptiontime import InceptionTimeClassifierTorch

estimator = InceptionTimeClassifierTorch(num_epochs: int=1500, n_conv_layers: int=3, n_filters: int=32, batch_size: int=64, kernel_size: int=40, use_residual: bool=True, use_bottleneck: bool=True, bottleneck_size: int=32, depth: int=6, activation: str | Callable | None=None, activation_hidden: str | Callable='ReLU', activation_inception: str | Callable | None=None, optimizer: str | None | Callable='Adam', optimizer_kwargs: dict | None=None, criterion: str | None | Callable='CrossEntropyLoss', criterion_kwargs: dict | None=None, callbacks: None | str | tuple [str, ... ]=None, callback_kwargs: dict | None=None, metrics: None | str | Callable | tuple [str | Callable, ... ]=None, lr: float=0.001, init_weights: str | None=None, verbose: bool=False, random_state: int | None=None)

Parameters(23)

num_epochsint, default=1500
The number of epochs to train the model.
n_conv_layersint, default=3
Number of convolutional branches in each inception module. Make sure base kernel size is divisible by 2^(n_conv_layers-1) to avoid errors. This implementation is adapted from [1].
n_filtersint, default=32
Number of filters in the convolution layers
batch_sizeint, default=64
The size of each mini-batch during training.
kernel_sizeint, default=40
Base kernel size for inception modules
use_residualbool, default=True
If True, uses residual connections
use_bottleneckbool, default=True
If True, uses bottleneck layer in inception modules.
bottleneck_sizeint, default=32
Size of the bottleneck layer.
depthint, default=6
Number of inception modules to stack.
activation: str or callable or None, default=None
Activation function used for the final output layer. Recommended: ‘ReLU’, ‘Tanh’, ‘Sigmoid’, ‘LeakyReLU’, ‘ELU’, ‘SELU’, ‘GELU’, None
activation_hiddenstr or callable, default=”ReLU”
Activation function used for hidden layers (output from inception modules). Recommended: ‘ReLU’, ‘Tanh’, ‘Sigmoid’, ‘LeakyReLU’, ‘ELU’, ‘SELU’, ‘GELU’
activation_inceptionstr or callable or None, default=None
Activation function used inside the inception modules. Recommended: ‘ReLU’, ‘Tanh’, ‘Sigmoid’, ‘LeakyReLU’, ‘ELU’, ‘SELU’, ‘GELU’, None
optimizercase insensitive str or None or an instance of optimizers
defined in torch.optim, default = “Adam” The optimizer to use for training the model.
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 = “CrossEntropyLoss” The loss function to be used in training the neural network.
criterion_kwargsdict or None, default = None
Additional keyword arguments to pass to the loss function.
callbacksNone or str or a tuple of str, default = None
Currently only learning rate schedulers are supported as callbacks.
callback_kwargsdict or None, default = None
The keyword arguments to be passed to the callbacks.
metricsNone or str or Callable or tuple of str and/or Callable, default = None

Metrics to compute during training. If None, no metrics are computed beyond the loss. Metrics are computed from torchmetrics library. If a string/Callable is passed, it must be one of the metrics defined in https://lightning.ai/docs/torchmetrics/stable/ Examples: “Accuracy”, “F1Score”, “Precision”, “Recall”

lrfloat, default = 0.001
The learning rate to use for the optimizer.
init_weightsstr or None, default = None
The method to initialize the weights of the conv layers. Supported values are ‘kaiming_uniform’, ‘kaiming_normal’, ‘xavier_uniform’, ‘xavier_normal’, or None for default PyTorch initialization.
verbosebool, default = False
Whether to print progress information during training.
random_stateint or None, default = None
Seed to ensure reproducibility.

Examples

Single instance of InceptionTime model:
>>> from sktime.classification.deep_learning.inceptiontime import (… InceptionTimeClassifierTorch …)
>>> 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”)
>>> clf = InceptionTimeClassifierTorch(# doctest: +SKIP … num_epochs=50, batch_size=2 …)
>>> clf.fit(X_train, y_train) # doctest: +SKIP InceptionTimeClassifierTorch(…) To build an ensemble of models mirroring [1]_, use the BaggingClassifier:
>>> from sktime.classification.ensemble import BaggingClassifier
>>> from sktime.classification.deep_learning.inceptiontime import (… InceptionTimeClassifierTorch …)
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test(split=”train”) # doctest: +SKIP
>>> X_test, y_test = load_unit_test(split=”test”) # doctest: +SKIP
>>> clf = BaggingClassifier(… InceptionTimeClassifierTorch(), … n_estimators=5, … bootstrap=False …) # doctest: +SKIP
>>> clf.fit(X_train, y_train) # doctest: +SKIP BaggingClassifier(…)