MCDCNNClassifierTorch
Multi Channel Deep Convolutional Neural Classifier in PyTorch, adopted from [1].
Quickstart
from sktime.classification.deep_learning.mcdcnn import MCDCNNClassifierTorch
estimator = MCDCNNClassifierTorch(n_epochs: int=120, batch_size: int=16, kernel_sizes: tuple [int, ... ]=(5, 5), pool_size: int=2, filter_sizes: tuple [int, ... ]=(8, 8), dense_units: int=732, conv_padding: str | None='same', pool_padding: str | None='same', activation: str | None | Callable=None, activation_hidden: str | Callable='ReLU', use_bias: bool=True, criterion: str | None | Callable='CrossEntropyLoss', criterion_kwargs: dict | None=None, optim: str | None | Callable=None, optim_kwargs: dict | None=None, callbacks: str | tuple [str, ... ] | None=None, callback_kwargs: dict | None=None, metrics: None | str | Callable | tuple [str | Callable, ... ]=None, lr: float=0.01, verbose: bool=False, random_state: int=0)Parameters(22)
- n_epochsint, optional (default=120)
- The number of epochs to train the model.
- batch_sizeint, optional (default=16)
- The number of samples per gradient update.
- kernel_sizestuple, optional (default=(5, 5))
- The size of kernels in Conv1D layers.
- pool_sizeint, optional (default=2)
- The size of kernel in (Max) Pool layer.
- filter_sizestuple, 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_unitsint, 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_paddingstr or None, optional (default=”same”)
- The type of padding to be applied to convolutional layers.
- pool_paddingstr or None, optional (default=”same”)
- The type of padding to be applied to pooling layers.
- criterionstr, optional (default=”CrossEntropyLoss”)
- The name of the loss function to be used during training, should be supported by PyTorch.
- activationstr or Callable or None, optional (default=None)
The activation function to apply at the output. List of available activation functions: https://pytorch.org/docs/stable/nn.html#non-linear-activations-activation When using CrossEntropyLoss (default) as the loss function, the activation function in the output layer must be None.
- activation_hiddenstr or Callable, default=”ReLU”
Activation function used in the hidden layers. List of available activation functions: https://pytorch.org/docs/stable/nn.html#non-linear-activations-activation
- use_biasbool, optional (default=True)
- Whether bias should be included in the output layer.
- criterionstr, optional (default=”CrossEntropyLoss”)
- The name of the loss function to be used during training, should be supported by PyTorch.
- criterion_kwargsdict or None, optional (default=None)
- Additional keyword arguments to pass to the criterion.
- optimstr or None or an 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_kwargsdict or None, optional (default=None)
- Additional keyword arguments to pass to the optimizer.
- callbacksNone 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_kwargsdict or None, optional (default=None)
- The keyword arguments to be passed to the callbacks.
- metricsNone 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”
- lrfloat, optional (default=0.01)
- The learning rate to use for the optimizer.
- verbosebool, optional (default=False)
- Whether to print progress information during training.
- random_stateint, optional (default=0)
- The seed to any random action.
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 ()
>>> mcdcnn. fit (X_train, y_train) MCDCNNClassifierTorch(
... )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.