TapNetClassifierTorchSKTimeWrapper
Python template · sinapsis_sktime.templates.sktime_classifiers
Overview
Template for SkTime classification model training and inference for the deep_learning module.
TapNetClassifierTorch — inherited documentation
TapNet classifier in PyTorch.
Parameters ---------- filter_sizes : tuple of int, default = (256, 256, 128) Number of convolutional filters in each conv block. If ``use_rp`` is True, the first conv layer is group-specific and all subsequent conv layers share parameters across groups. kernel_size : tuple of int, default = (8, 5, 3) Specifying the length of the 1D convolution window. layers : tuple of int, default = (500, 300) Sizes of dense layers in the mapping section. Any length >= 1 is allowed. dropout : float, default = 0.5 Dropout rate for the convolutional layers. lstm_dropout : float, default = 0.8 Dropout rate for the LSTM layer. dilation : int, default = 1 Dilation value. 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="LeakyReLU" 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_rp : bool, default = True Whether to use random projections. rp_group : int, default = 3 Number of random permutation groups g for random dimension permutation (RDP). Must be a positive integer. rp_alpha : float, default = 2.0 Scale factor alpha used to compute the RDP group size: rp_dim = floor(n_dims * rp_alpha / rp_group). If rp_dim becomes 0, RDP is disabled with a warning (RDP requires multivariate inputs). Must be positive. use_att : bool, default = True Whether to use self attention. use_lstm : bool, default = True Whether to use an LSTM layer. use_cnn : bool, default = True Whether to use a CNN layer. padding : str, default = "same" Type of padding for convolution layers. init_weights : bool, default = True Whether to apply custom initialization. fc_dropout : float, default = 0.0 Dropout rate before the output layer. 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.
Examples -------- >>> from sktime.classification.deep_learning.tapnet import TapNetClassifierTorch >>> 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 = TapNetClassifierTorch(num_epochs=20, batch_size=4) # doctest: +SKIP >>> clf.fit(X_train, y_train) # doctest: +SKIP TapNetClassifierTorch(...)
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. tapnetclassifiertorch_init filter_sizes typing.Optional[tuple[int, ...]]: default: (256, 256, 128) kernel_size typing.Optional[tuple[int, ...]]: default: (8, 5, 3) layers… Read full field description
Path where the trained model will be saved. tapnetclassifiertorch_init filter_sizes typing.Optional[tuple[int, ...]]: default: (256, 256, 128) kernel_size typing.Optional[tuple[int, ...]]: default: (8, 5, 3) layers typing.Optional[tuple[int, ...]]: default: (500, 300) dropout <class 'float'>: default: 0.5 lstm_dropout <class 'float'>: default: 0.8 dilation <class 'int'>: default: 1 activation typing.Union[str, collections.abc.Callable, NoneType]: default: None activation_hidden typing.Union[str, collections.abc.Callable, NoneType]: default: LeakyReLU use_rp <class 'bool'>: default: True rp_group <class 'int'>: default: 3 rp_alpha <class 'float'>: default: 2.0 use_att <class 'bool'>: default: True use_lstm <class 'bool'>: default: True use_cnn <class 'bool'>: default: True padding <class 'str'>: default: same init_weights <class 'bool'>: default: True fc_dropout <class 'float'>: default: 0.0 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: [500,300]
Optional
Default: true
Optional
Default: 0.5
Optional
Default: null
Optional
Default: "same"
Optional
Default: true
Optional
Default: true
Optional
Default: false
Optional
Default: 1
Optional
Default: 2
Optional
Default: 3
Optional
Default: true
Optional
Default: "ReduceLROnPlateau"
Optional
Default: "CrossEntropyLoss"
Optional
Default: "RMSprop"
Optional
Default: null
Optional
Default: 1
Optional
Default: 0
Optional
Default: 100
Optional
Default: [8,5,3]
Optional
Default: [256,256,128]
Optional
Default: true
Optional
Default: 0.8
Optional
Default: 0
Optional
Default: null
Optional
Default: null
Optional
Default: null
Optional
Default: "LeakyReLU"
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "TapNetClassifierTorchSKTimeWrapper"
class_name: "TapNetClassifierTorchSKTimeWrapper"
attributes:
root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
model_save_path: "<required>"
tapnetclassifiertorch_init:
lr: 0.001
layers: [500, 300]
use_rp: true
dropout: 0.5
metrics: null
padding: "same"
use_att: true
use_cnn: true
verbose: false
dilation: 1
rp_alpha: 2
rp_group: 3
use_lstm: true
callbacks: "ReduceLROnPlateau"
criterion: "CrossEntropyLoss"
optimizer: "RMSprop"
activation: null
batch_size: 1
fc_dropout: 0
num_epochs: 100
kernel_size: [8, 5, 3]
filter_sizes: [256, 256, 128]
init_weights: true
lstm_dropout: 0.8
random_state: 0
callback_kwargs: null
criterion_kwargs: null
optimizer_kwargs: null
activation_hidden: "LeakyReLU"
Inheritance
sinapsis_sktime.templates.sktime_classifiers.SKTimeDeepLearningClassifiersEnvironment variables
Environment definitions belong to their canonical Python modules.