ResNetClassifierTorchSKTimeWrapper
Python template · sinapsis_sktime.templates.sktime_classifiers
Overview
Template for SkTime classification model training and inference for the deep_learning module.
ResNetClassifierTorch — inherited documentation
Residual neural network classifier in PyTorch, as described in [1].
Adapted from the implementation from source code https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/resnet.py
Parameters ---------- n_filters : tuple of int, default = (64, 128, 128) Number of convolutional filters in each residual block. The length of this tuple determines the number of residual blocks. Any length >= 1 is allowed. kernel_size : tuple of int, default = (8, 5, 3) Length of the 1D convolution window for the conv layers within a residual block, shared across all residual blocks. Any length >= 1 is allowed. 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.
activation_hidden : str, Callable, or None, default="ReLU" Activation applied to the hidden layers, and after each residual connection.
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.
init_weights : bool, default = True Whether to apply custom initialization to the weights. num_epochs : int, default = 100 The number of epochs to train the model. batch_size : int, default = 1 The size of each mini-batch during training. optimizer : str or None, or a class or instance of optimizers defined in torch.optim, default = "RMSprop" The optimizer to use for training the model. List of available optimizers: https://pytorch.org/docs/stable/optim.html#algorithms criterion : 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. List of available loss functions: https://pytorch.org/docs/stable/nn.html#loss-functions callbacks : None or str or a tuple of str, default = "ReduceLROnPlateau" Learning rate schedulers applied during training. 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. Note: Since PyTorch learning rate schedulers need to be initialized with the optimizer object, we only accept the class name (str) of the scheduler here and do not accept an instance of the scheduler. As that can lead to errors and unexpected behavior. List of available learning rate schedulers: https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate optimizer_kwargs : dict or None, default = None Additional keyword arguments to pass to the optimizer. criterion_kwargs : dict or None, default = None Additional keyword arguments to pass to the loss function. 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. verbose : bool, default = False Whether to print progress information during training. random_state : int, default = 0 Seed to ensure reproducibility.
References ---------- .. [1] Wang et al, Time series classification from scratch with deep neural networks: A strong baseline, International joint conference on neural networks (IJCNN), 2017.
Examples -------- >>> from sktime.classification.deep_learning.resnet import ResNetClassifierTorch >>> 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 = ResNetClassifierTorch(num_epochs=20, batch_size=4) # doctest: +SKIP >>> clf.fit(X_train, y_train) # doctest: +SKIP ResNetClassifierTorch(...)
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-sktime==1.0.0uv pip install sinapsis-sktime==1.0.0uv add sinapsis-sktime==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Optional
Default: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
Path where the trained model will be saved. resnetclassifiertorch_init n_filters typing.Optional[tuple[int, ...]]: default: (64, 128, 128) kernel_size typing.Optional[tuple[int, ...]]: default: (8, 5, 3) activation… Read full field description
Path where the trained model will be saved. resnetclassifiertorch_init n_filters typing.Optional[tuple[int, ...]]: default: (64, 128, 128) kernel_size typing.Optional[tuple[int, ...]]: default: (8, 5, 3) activation typing.Union[str, collections.abc.Callable, NoneType]: default: None activation_hidden typing.Union[str, collections.abc.Callable, NoneType]: default: ReLU init_weights <class 'bool'>: default: True num_epochs <class 'int'>: default: 100 batch_size <class 'int'>: default: 1 optimizer typing.Union[str, collections.abc.Callable, NoneType]: default: RMSprop criterion typing.Union[str, collections.abc.Callable, NoneType]: default: CrossEntropyLoss callbacks typing.Union[NoneType, str, tuple[str, ...]]: default: ReduceLROnPlateau optimizer_kwargs typing.Optional[dict]: default: None criterion_kwargs typing.Optional[dict]: 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 verbose <class 'bool'>: default: False random_state <class 'int'>: default: 0
Required
Default: null
Required
Default: null
Optional
Default: 0.001
Optional
Default: null
Optional
Default: false
Optional
Default: "ReduceLROnPlateau"
Optional
Default: "CrossEntropyLoss"
Optional
Default: [64,128,128]
Optional
Default: "RMSprop"
Optional
Default: null
Optional
Default: 1
Optional
Default: 100
Optional
Default: [8,5,3]
Optional
Default: true
Optional
Default: 0
Optional
Default: null
Optional
Default: null
Optional
Default: null
Optional
Default: "ReLU"
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "ResNetClassifierTorchSKTimeWrapper"
class_name: "ResNetClassifierTorchSKTimeWrapper"
attributes:
root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
model_save_path: "<required>"
resnetclassifiertorch_init:
lr: 0.001
metrics: null
verbose: false
callbacks: "ReduceLROnPlateau"
criterion: "CrossEntropyLoss"
n_filters: [64, 128, 128]
optimizer: "RMSprop"
activation: null
batch_size: 1
num_epochs: 100
kernel_size: [8, 5, 3]
init_weights: true
random_state: 0
callback_kwargs: null
criterion_kwargs: null
optimizer_kwargs: null
activation_hidden: "ReLU"
Inheritance
sinapsis_sktime.templates.sktime_classifiers.SKTimeDeepLearningClassifiersEnvironment variables
Environment definitions belong to their canonical Python modules.