Docs /Templates/ sinapsis-sktime

MCDCNNClassifierTorchSKTimeWrapper

sinapsis-sktimeSKTimedynamicinferencemodelsprediction

Python template · sinapsis_sktime.templates.sktime_classifiers

Overview

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

MCDCNNClassifierTorch — inherited documentation

Multi Channel Deep Convolutional Neural Classifier in PyTorch, adopted from [1]_.

Adapted from the implementation of Fawaz et. al https://github.com/hfawaz/dl-4-tsc/blob/master/classifiers/mcdcnn.py

Parameters ---------- n_epochs : int, optional (default=120) The number of epochs to train the model. batch_size : int, optional (default=16) The number of samples per gradient update. kernel_sizes : tuple, optional (default=(5, 5)) The size of kernels in Conv1D layers. pool_size : int, optional (default=2) The size of kernel in (Max) Pool layer. filter_sizes : tuple, optional (default=(8, 8)) The sizes of filter for Conv1D layer corresponding to each Conv1D in the block. Number of conv layers is determined by the length of this tuple. dense_units : int, optional (default=732) The number of output units of the final Dense layer of this Network. This is NOT the final layer but the penultimate layer. conv_padding : str or None, optional (default="same") The type of padding to be applied to convolutional layers. pool_padding : str or None, optional (default="same") The type of padding to be applied to pooling layers. criterion : str, optional (default="CrossEntropyLoss") The name of the loss function to be used during training, should be supported by PyTorch. activation : str, Callable, or None, optional (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.

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.

use_bias : bool, optional (default=True) Whether bias should be included in the output layer. criterion : str, optional (default="CrossEntropyLoss") The name of the loss function to be used during training, should be supported by PyTorch. criterion_kwargs : dict or None, optional (default=None) Additional keyword arguments to pass to the criterion. optim : str or None, or a class or instance of optimizers defined in torch.optim, optional (default=None) The optimizer to use for training the model. If left as None, SGD is used with momentum=0.9, weight_decay=0.0005. List of available optimizers: https://pytorch.org/docs/stable/optim.html#algorithms optim_kwargs : dict or None, optional (default=None) Additional keyword arguments to pass to the optimizer. callbacks : None or str or a tuple of str, optional (default=None) 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. callback_kwargs : dict or None, optional (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, optional (default=0.01) The learning rate to use for the optimizer. verbose : bool, optional (default=False) Whether to print progress information during training. random_state : int, optional (default=0) The seed to any random action.

References ---------- .. [1] Zheng et. al, Time series classification using multi-channels deep convolutional neural networks, International Conference on Web-Age Information Management, Pages 298-310, year 2014, organization: Springer.

Examples -------- >>> from sktime.classification.deep_learning.mcdcnn import MCDCNNClassifierTorch >>> from sktime.datasets import load_unit_test >>> X_train, y_train = load_unit_test(split="train") >>> mcdcnn = MCDCNNClassifierTorch() # doctest: +SKIP >>> mcdcnn.fit(X_train, y_train) # doctest: +SKIP MCDCNNClassifierTorch(...)

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. mcdcnnclassifiertorch_init n_epochs <class 'int'>: default: 120 batch_size <class 'int'>: default: 16 kernel_sizes typing.Optional[tuple[int, ...]]: default: (5, 5) pool_size… Read full field description

Path where the trained model will be saved. mcdcnnclassifiertorch_init n_epochs <class 'int'>: default: 120 batch_size <class 'int'>: default: 16 kernel_sizes typing.Optional[tuple[int, ...]]: default: (5, 5) pool_size <class 'int'>: default: 2 filter_sizes typing.Optional[tuple[int, ...]]: default: (8, 8) dense_units <class 'int'>: default: 732 conv_padding typing.Optional[str]: default: same pool_padding typing.Optional[str]: default: same activation typing.Union[str, collections.abc.Callable, NoneType]: default: None activation_hidden typing.Union[str, collections.abc.Callable, NoneType]: default: ReLU use_bias <class 'bool'>: default: True criterion typing.Union[str, collections.abc.Callable, NoneType]: default: CrossEntropyLoss criterion_kwargs typing.Optional[dict]: default: None optim typing.Union[str, collections.abc.Callable, NoneType]: default: None optim_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.01 verbose <class 'bool'>: default: False random_state <class 'int'>: default: 0

str
Required
Default: null
mcdcnnclassifiertorch_initRequired
MCDCNNClassifierTorchAttributes
Required
Default: null
lr
float
Optional
Default: 0.01
optim
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: null
metrics
typing.Union[NoneType, str, collections.abc.Callable, tuple[str | collections.abc.Callable, ...]]
Optional
Default: null
verbose
bool
Optional
Default: false
n_epochs
int
Optional
Default: 120
use_bias
bool
Optional
Default: true
callbacks
typing.Union[NoneType, str, tuple[str, ...]]
Optional
Default: null
criterion
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "CrossEntropyLoss"
pool_size
int
Optional
Default: 2
activation
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: null
batch_size
int
Optional
Default: 16
dense_units
int
Optional
Default: 732
conv_padding
typing.Optional[str]
Optional
Default: "same"
filter_sizes
typing.Optional[tuple[int, ...]]
Optional
Default: [8,8]
kernel_sizes
typing.Optional[tuple[int, ...]]
Optional
Default: [5,5]
optim_kwargs
typing.Optional[dict]
Optional
Default: null
pool_padding
typing.Optional[str]
Optional
Default: "same"
random_state
int
Optional
Default: 0
callback_kwargs
typing.Optional[dict]
Optional
Default: null
criterion_kwargs
typing.Optional[dict]
Optional
Default: null
activation_hidden
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "ReLU"

Configuration example

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

yaml
templates:
  - template_name: "MCDCNNClassifierTorchSKTimeWrapper"
    class_name: "MCDCNNClassifierTorchSKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      model_save_path: "<required>"
      mcdcnnclassifiertorch_init:
        lr: 0.01
        optim: null
        metrics: null
        verbose: false
        n_epochs: 120
        use_bias: true
        callbacks: null
        criterion: "CrossEntropyLoss"
        pool_size: 2
        activation: null
        batch_size: 16
        dense_units: 732
        conv_padding: "same"
        filter_sizes: [8, 8]
        kernel_sizes: [5, 5]
        optim_kwargs: null
        pool_padding: "same"
        random_state: 0
        callback_kwargs: null
        criterion_kwargs: null
        activation_hidden: "ReLU"

Inheritance

Immediate parent: sinapsis_sktime.templates.sktime_classifiers.SKTimeDeepLearningClassifiers

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere