Back to models
Classifier

MACNNClassifier

Multi-Scale Attention Convolutional Neural Classifier, as described in [1].

Quickstart

python
from sktime.classification.deep_learning.macnn import MACNNClassifier

estimator = MACNNClassifier(n_epochs=1500, batch_size=4, padding='same', pool_size=3, strides=2, repeats=2, filter_sizes=(64, 128, 256), kernel_size=(3, 6, 12), reduction=16, loss='categorical_crossentropy', activation='sigmoid', activation_hidden='relu', use_bias=True, metrics=None, optimizer=None, callbacks=None, random_state=0, verbose=False)

Parameters(18)

n_epochsint, optional (default=1500)
The number of epochs to train the model.
batch_sizeint, optional (default=4)
The number of sample per gradient update.
paddingstr, optional (default=”same”)
The type of padding to be provided in MACNN Blocks. Accepts all the string values that keras.layers supports. Note: For Conv1D layers within MACNN Blocks, padding is always set to “same” to ensure consistent output lengths for multi-scale convolutions. This parameter only affects the pooling layers between MACNN Blocks.
pool_sizeint, optional (default=3)
A single value representing pooling windows which are applied between two MACNN Blocks.
stridesint, optional (default=2)
A single value representing strides to be taken during the pooling operation.
repeatsint, optional (default=2)
The number of MACNN Blocks to be stacked.
filter_sizestuple, optional (default=(64, 128, 256))
The input size of Conv1D layers within each MACNN Block.
kernel_sizetuple, optional (default=(3, 6, 12))
The output size of Conv1D layers within each MACNN Block.
reductionint, optional (default = 16)
The factor by which the first dense layer of a MACNN Block will be divided by.
lossstr, optional (default=”categorical_crossentropy”)
The name of the loss function to be used during training, should be supported by keras.
activationstr, optional (default=”sigmoid”)

The activation function to apply at the output. List of available activation functions: https://keras.io/api/layers/activations/

activation_hiddenstring or a tf callable, default=”relu”

Activation function used in the hidden layers. List of available activation functions: https://keras.io/api/layers/activations/

use_biasbool, optional (default=True)
Whether bias should be included in the output layer.
metricsNone or string, optional (default=None)

The string which will be used during model compilation. If left as None, then “accuracy” is passed to model.compile().

optimizer: None or keras.optimizers.Optimizer instance, optional (default=None)

The optimizer that is used for model compiltation. If left as None, then keras.optimizers.Adam(learning_rate=0.0001) is used.

callbacksNone or list of keras.callbacks.Callback, optional (default=None)
The callback(s) to use during training.
random_stateint, optional (default=0)
The seed to any random action.
verbosebool, optional (default=False)

Verbosity during model training, making it True will print model summary, training information etc.

Examples

>>> from sktime.classification.deep_learning.macnn import MACNNClassifier
>>> 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")
>>> macnn = MACNNClassifier (n_epochs = 3)
>>> macnn. fit (X_train, y_train) MACNNClassifier(
... )

References

  1. [1 ] Wei Chen et. al, Multi-scale Attention Convolutional Neural Network for time series classification, Neural Networks, Volume 136, 2021, Pages 126-140, ISSN 0893-6080, https://doi.org/10.1016/j.neunet.2021.01.001.