Docs /Templates/ sinapsis-sktime

SimpleRNNClassifierTorchSKTimeWrapper

sinapsis-sktimeSKTimedynamicinferencemodelsprediction

Python template · sinapsis_sktime.templates.sktime_classifiers

Overview

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

SimpleRNNClassifierTorch — inherited documentation

Simple recurrent neural network in PyTorch for time series classification.

Parameters ---------- hidden_dim : int, default = 6 Number of features in the hidden state. n_layers : int, default = 1 Number of recurrent layers. Setting n_layers=2 would mean stacking two RNNs together to form a stacked RNN, with the second RNN taking in outputs of the first RNN and computing the final results. 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 inside the RNN.

Permitted values:

- ``None``: no activation is applied inside the RNN. - ``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``. Because currently PyTorch only supports these two activations inside the RNN. https://docs.pytorch.org/docs/stable/generated/torch.nn.RNN.html#torch.nn.RNN bias : bool, default = True If False, then the layer does not use bias weights. init_weights : bool, default = True If True, then the weights are initialized. dropout : float, default = 0.0 If non-zero, introduces a Dropout layer on the outputs of each RNN layer except the fully connected output layer, with dropout probability equal to dropout. fc_dropout : float, default = 0.0 If non-zero, introduces a Dropout layer on the outputs of the fully connected output layer, with dropout probability equal to fc_dropout. bidirectional : bool, default = False If True, then the RNN is bidirectional. num_epochs : int, default = 100 The number of epochs to train the model. optimizer : case insensitive 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 optimizer_kwargs : dict or None, default = None Additional keyword arguments to pass to the optimizer. batch_size : int, default = 1 The size of each mini-batch during training. 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. List of available loss functions: https://pytorch.org/docs/stable/nn.html#loss-functions 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 = "ReduceLROnPlateau" 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 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.rnn import SimpleRNNClassifierTorch >>> 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 = SimpleRNNClassifierTorch(n_epochs=50,batch_size=2) # doctest: +SKIP >>> clf.fit(X_train, y_train) # doctest: +SKIP SimpleRNNClassifierTorch(...)

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. simplernnclassifiertorch_init hidden_dim <class 'int'>: default: 6 n_layers <class 'int'>: default: 1 activation typing.Union[str, collections.abc.Callable, NoneType]:… Read full field description

Path where the trained model will be saved. simplernnclassifiertorch_init hidden_dim <class 'int'>: default: 6 n_layers <class 'int'>: default: 1 activation typing.Union[str, collections.abc.Callable, NoneType]: default: None activation_hidden typing.Union[str, collections.abc.Callable, NoneType]: default: ReLU bias <class 'bool'>: default: True init_weights <class 'bool'>: default: True dropout <class 'float'>: default: 0.0 fc_dropout <class 'float'>: default: 0.0 bidirectional <class 'bool'>: default: False 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

str
Required
Default: null
simplernnclassifiertorch_initRequired
SimpleRNNClassifierTorchAttributes
Required
Default: null
lr
float
Optional
Default: 0.001
bias
bool
Optional
Default: true
dropout
float
Optional
Default: 0
metrics
typing.Union[NoneType, str, collections.abc.Callable, tuple[str | collections.abc.Callable, ...]]
Optional
Default: null
verbose
bool
Optional
Default: false
n_layers
int
Optional
Default: 1
callbacks
typing.Union[NoneType, str, tuple[str, ...]]
Optional
Default: "ReduceLROnPlateau"
criterion
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "CrossEntropyLoss"
optimizer
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: "RMSprop"
activation
typing.Union[str, collections.abc.Callable, NoneType]
Optional
Default: null
batch_size
int
Optional
Default: 1
fc_dropout
float
Optional
Default: 0
hidden_dim
int
Optional
Default: 6
num_epochs
int
Optional
Default: 100
init_weights
bool
Optional
Default: true
random_state
int
Optional
Default: 0
bidirectional
bool
Optional
Default: false
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"

Configuration example

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

yaml
templates:
  - template_name: "SimpleRNNClassifierTorchSKTimeWrapper"
    class_name: "SimpleRNNClassifierTorchSKTimeWrapper"
    attributes:
      root_dir: "/sinapsis-hub/private/platform/sinapsis-hub/playground/publish"
      model_save_path: "<required>"
      simplernnclassifiertorch_init:
        lr: 0.001
        bias: true
        dropout: 0
        metrics: null
        verbose: false
        n_layers: 1
        callbacks: "ReduceLROnPlateau"
        criterion: "CrossEntropyLoss"
        optimizer: "RMSprop"
        activation: null
        batch_size: 1
        fc_dropout: 0
        hidden_dim: 6
        num_epochs: 100
        init_weights: true
        random_state: 0
        bidirectional: false
        callback_kwargs: null
        criterion_kwargs: null
        optimizer_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