Docs /Templates/ sinapsis-sktime

InceptionTimeClassifierTorchSKTimeWrapper

sinapsis-sktimeSKTimedynamicinferencemodelsprediction

Python template · sinapsis_sktime.templates.sktime_classifiers

Overview

Template for SkTime classification model training and inference for the deep_learning module.

InceptionTimeClassifierTorch — inherited documentation

InceptionTime Deep Learning Classifier in PyTorch.

Adapted from the implementation from Fawaz et. al https://github.com/hfawaz/InceptionTime/blob/master/classifiers/inception.py

InceptionTimeClassifierTorch is a single instance of InceptionTime model described in the original publication [1]_, which uses an ensemble of 5 single instances.

To build an ensemble of models mirroring [1]_, use the BaggingClassifier with n_estimators=5, bootstrap=False, and estimator being an instance of this InceptionTimeClassifierTorch.

Parameters ---------- num_epochs : int, default=1500 The number of epochs to train the model. n_conv_layers : int, 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_filters : int, default=32 Number of filters in the convolution layers batch_size : int, default=64 The size of each mini-batch during training. kernel_size : int, default=40 Base kernel size for inception modules use_residual : bool, default=True If True, uses residual connections use_bottleneck : bool, default=True If True, uses bottleneck layer in inception modules. bottleneck_size : int, default=32 Size of the bottleneck layer. depth : int, default=6 Number of inception modules to stack. activation : str, Callable, or None, default=None Activation applied to the output layer.

Permitted values:

- ``None``: no activation is applied to the output layer and the network returns raw outputs (logits). This is typically required when using ``CrossEntropyLoss``, which expects logits as input. - ``str``: name of a class in ``torch.nn``. Case-sensitive names are recommended and must match PyTorch (e.g., ``"ReLU"``, ``"LeakyReLU"``). Lowercase aliases for common activations are also accepted (e.g., ``"relu"`` is resolved to ``"ReLU"``). The class is instantiated with default constructor arguments. Must be a valid ``torch.nn`` activation; see https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity - ``torch.nn.Module``: an instance of a ``torch.nn.Module`` subclass, for example ``torch.nn.ReLU()``. Arbitrary callables are not supported.

Recommended activations: ``ReLU``, ``Tanh``, ``Sigmoid``, ``LeakyReLU``, ``ELU``, ``SELU``, ``GELU``. activation_hidden : str, Callable, or None, default="ReLU" Activation applied to the hidden layers (output from inception modules).

Permitted values:

- ``None``: no activation is applied to the hidden layers. - ``str``: name of a class in ``torch.nn``. Case-sensitive names are recommended and must match PyTorch (e.g., ``"ReLU"``, ``"LeakyReLU"``). Lowercase aliases for common activations are also accepted (e.g., ``"relu"`` is resolved to ``"ReLU"``). The class is instantiated with default constructor arguments. Must be a valid ``torch.nn`` activation; see https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity - ``torch.nn.Module``: an instance of a ``torch.nn.Module`` subclass, for example ``torch.nn.ReLU()``. Arbitrary callables are not supported.

Recommended activations: ``ReLU``, ``Tanh``, ``Sigmoid``, ``LeakyReLU``, ``ELU``, ``SELU``, ``GELU``. activation_inception : str, Callable, or None, default=None Activation applied inside the inception modules.

Permitted values:

- ``None``: no activation is applied inside the inception modules. - ``str``: name of a class in ``torch.nn``. Case-sensitive names are recommended and must match PyTorch (e.g., ``"ReLU"``, ``"LeakyReLU"``). Lowercase aliases for common activations are also accepted (e.g., ``"relu"`` is resolved to ``"ReLU"``). The class is instantiated with default constructor arguments. Must be a valid ``torch.nn`` activation; see https://pytorch.org/docs/stable/nn.html#non-linear-activations-weighted-sum-nonlinearity - ``torch.nn.Module``: an instance of a ``torch.nn.Module`` subclass, for example ``torch.nn.ReLU()``. Arbitrary callables are not supported.

Recommended activations: ``ReLU``, ``Tanh``, ``Sigmoid``, ``LeakyReLU``, ``ELU``, ``SELU``, ``GELU``, None. optimizer : case insensitive str or None, or a class or instance of optimizers defined in torch.optim, default = "Adam" The optimizer to use for training the model. optimizer_kwargs : dict or None, default = None Additional keyword arguments to pass to the optimizer. criterion : case 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_kwargs : dict or None, default = None Additional keyword arguments to pass to the loss function. callbacks : None or str or a tuple of str, default = None Currently only learning rate schedulers are supported as callbacks. callback_kwargs : dict or None, default = None The keyword arguments to be passed to the callbacks. metrics : None 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" lr : float, default = 0.001 The learning rate to use for the optimizer. init_weights : str 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. verbose : bool, default = False Whether to print progress information during training. random_state : int or None, default = None Seed to ensure reproducibility.

Notes ----- ..[1] Fawaz et. al, InceptionTime: Finding AlexNet for Time Series Classification, Data Mining and Knowledge Discovery, 34, 2020

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(...)

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-sktime==1.0.0
uv pip install sinapsis-sktime==1.0.0
uv add sinapsis-sktime==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
root_dir
str
Optional
Default: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
model_save_pathRequired
Path where the trained model will be saved. inceptiontimeclassifiertorch_init num_epochs <class 'int'>: default: 1500 n_conv_layers <class 'int'>: default: 3 n_filters <class 'int'>: default: 32 batch_size <class… Read full field description

Path where the trained model will be saved. inceptiontimeclassifiertorch_init num_epochs <class 'int'>: default: 1500 n_conv_layers <class 'int'>: default: 3 n_filters <class 'int'>: default: 32 batch_size <class 'int'>: default: 64 kernel_size <class 'int'>: default: 40 use_residual <class 'bool'>: default: True use_bottleneck <class 'bool'>: default: True bottleneck_size <class 'int'>: default: 32 depth <class 'int'>: default: 6 activation typing.Union[str, collections.abc.Callable, NoneType]: default: None activation_hidden typing.Union[str, collections.abc.Callable, NoneType]: default: ReLU activation_inception typing.Union[str, collections.abc.Callable, NoneType]: default: None optimizer typing.Union[str, collections.abc.Callable, NoneType]: default: Adam optimizer_kwargs typing.Optional[dict]: default: None criterion typing.Union[str, collections.abc.Callable, NoneType]: default: CrossEntropyLoss criterion_kwargs typing.Optional[dict]: default: None callbacks typing.Union[NoneType, str, tuple[str, ...]]: default: None callback_kwargs typing.Optional[dict]: default: None metrics typing.Union[NoneType, str, collections.abc.Callable, tuple[str | collections.abc.Callable, ...]]: default: None lr <class 'float'>: default: 0.001 init_weights typing.Optional[str]: default: None verbose <class 'bool'>: default: False random_state typing.Optional[int]: default: None

str
Required
Default: null
inceptiontimeclassifiertorch_initRequired
InceptionTimeClassifierTorchAttributes
Required
Default: null
lr
float
Optional
Default: 0.001
depth
int
Optional
Default: 6
metrics
typing.Union[NoneType, str, collections.abc.Callable, tuple[str | collections.abc.Callable, ...]]
Optional
Default: null
verbose
bool
Optional
Default: false
callbacks
typing.Union[NoneType, str, tuple[str, ...]]
Optional
Default: null
criterion
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "CrossEntropyLoss"
n_filters
int
Optional
Default: 32
optimizer
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "Adam"
activation
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: null
batch_size
int
Optional
Default: 64
num_epochs
int
Optional
Default: 1500
kernel_size
int
Optional
Default: 40
init_weights
typing.Optional[str]
Optional
Default: null
random_state
typing.Optional[int]
Optional
Default: null
use_residual
bool
Optional
Default: true
n_conv_layers
int
Optional
Default: 3
use_bottleneck
bool
Optional
Default: true
bottleneck_size
int
Optional
Default: 32
callback_kwargs
typing.Optional[dict]
Optional
Default: null
criterion_kwargs
typing.Optional[dict]
Optional
Default: null
optimizer_kwargs
typing.Optional[dict]
Optional
Default: null
activation_hidden
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "ReLU"
activation_inception
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: null

Configuration example

Generated from documented defaults. Replace any placeholders and complete required nested settings before running.

yaml
templates:
  - template_name: "InceptionTimeClassifierTorchSKTimeWrapper"
    class_name: "InceptionTimeClassifierTorchSKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      model_save_path: "<required>"
      inceptiontimeclassifiertorch_init:
        lr: 0.001
        depth: 6
        metrics: null
        verbose: false
        callbacks: null
        criterion: "CrossEntropyLoss"
        n_filters: 32
        optimizer: "Adam"
        activation: null
        batch_size: 64
        num_epochs: 1500
        kernel_size: 40
        init_weights: null
        random_state: null
        use_residual: true
        n_conv_layers: 3
        use_bottleneck: true
        bottleneck_size: 32
        callback_kwargs: null
        criterion_kwargs: null
        optimizer_kwargs: null
        activation_hidden: "ReLU"
        activation_inception: null

Inheritance

Immediate parent: sinapsis_sktime.templates.sktime_classifiers.SKTimeDeepLearningClassifiers

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere