Models Pytorch

Here the different deep learning models included in the library are summarised. All of them are developed in PyTorch.

TSFEDL.models_pytorch.TSFEDL_BaseModule(...)

Base module for any pyTorch Lightning based algorithm in this library

TSFEDL.models_pytorch.OhShuLih(in_features, ...)

CNN+LSTM model for Arrythmia classification.

TSFEDL.models_pytorch.KhanZulfiqar(...)

CNN+GRU model for electricity forecasting

TSFEDL.models_pytorch.ZhengZhenyu(...)

CNN+LSTM network for arrythmia detection.

TSFEDL.models_pytorch.WangKejun(in_features, ...)

CNN 1D-LSTM

TSFEDL.models_pytorch.ChenChen(in_features, ...)

CNN+LSTM model for arrythmia classification.

TSFEDL.models_pytorch.KimTaeYoung(...)

CNN+LSTM model for arrythmia classification.

TSFEDL.models_pytorch.GenMinxing(...)

CNN+LSTM model for arrythmia classification.

TSFEDL.models_pytorch.FuJiangmeng(...)

CNN+LSTM model for arrythmia classification.

TSFEDL.models_pytorch.ShiHaotian(...)

CNN+LSTM model for arrythmia classification.

TSFEDL.models_pytorch.HuangMeiLing(...)

CNN model, employed for 2-D images of ECG data. This model is adapted for 1-D time series

TSFEDL.models_pytorch.LihOhShu(in_features, ...)

CNN+LSTM model

TSFEDL.models_pytorch.GaoJunLi(in_features, ...)

LSTM network

TSFEDL.models_pytorch.WeiXiaoyan(...)

CNN+LSTM model employed for 2-D images of ECG data.

TSFEDL.models_pytorch.KongZhengmin(...)

CNN+LSTM

TSFEDL.models_pytorch.YildirimOzal(...)

CAE-LSTM

TSFEDL.models_pytorch.CaiWenjuan(...)

DDNN network presented in:

TSFEDL.models_pytorch.HtetMyetLynn(...)

Hybrid CNN+Bidirectional RNN

TSFEDL.models_pytorch.ZhangJin(in_features, ...)

A CNN+Bi-Directional GRU with a spatio-temporal attention mechanism.

TSFEDL.models_pytorch.YaoQihang(in_features, ...)

Attention-based time-incremental convolutional neural network (ATI-CNN)

TSFEDL.models_pytorch.YiboGao(in_features, ...)

CNN using RTA blocks for end-to-end attrial fibrilation detection.

TSFEDL.models_pytorch.SharPar(in_features, ...)

A 1-layer CNN + LSTM model.

TSFEDL.models_pytorch.DaiXiLi(in_features, ...)

A 1-layer CNN + LSTM model.

TSFEDL.models_pytorch.TSFEDL_BaseModule(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = None, loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

Base module for any pyTorch Lightning based algorithm in this library

Parameters:
  • in_features (int,) – The number of input features.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (List[Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – A dictionary of metrics to be returned in the test phase. These metric are functions that accepts two tensors as inputs, i.e., predictions and targets, and return another tensor with the metric value. Defaults contains the accuracy

  • top_module (nn.Module, defaults=None) – The optional nn.Module to be used as additional top layers.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

TSFEDL.models_pytorch.OhShuLih(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = OhShuLih_Classifier(   (model): Sequential(     (0): Dropout(p=0.2, inplace=False)     (1): Linear(in_features=20, out_features=20, bias=True)     (2): ReLU()     (3): Linear(in_features=20, out_features=10, bias=True)     (4): ReLU()     (5): Linear(in_features=10, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model for Arrythmia classification.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=OhShuLih_Classifier(20,5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Oh, Shu Lih, et al. “Automated diagnosis of arrhythmia using combination of CNN and LSTM techniques with variable length heart beats.” Computers in biology and medicine 102 (2018): 278-287.

TSFEDL.models_pytorch.KhanZulfiqar(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = KhanZulfiqar_Classifier(   (module): Sequential(     (0): Linear(in_features=10, out_features=8, bias=True)     (1): ReLU()     (2): Dropout(p=0.5, inplace=False)     (3): Linear(in_features=8, out_features=8, bias=True)     (4): ReLU()     (5): Dropout(p=0.5, inplace=False)     (6): Linear(in_features=8, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+GRU model for electricity forecasting

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=KhanZulfiqar_Classifier(10, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Sajjad, M., Khan, Z. A., Ullah, A., Hussain, T., Ullah, W., Lee, M. Y., & Baik, S. W. (2020). A novel CNN-GRU-based hybrid approach for short-term residential load forecasting. IEEE Access, 8, 143759-143768.

TSFEDL.models_pytorch.ZhengZhenyu(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = ZhengZhenyu_Classifier(   (module): Sequential(     (0): Linear(in_features=256, out_features=2048, bias=True)     (1): ELU(alpha=1.0)     (2): Dropout(p=0.5, inplace=False)     (3): Linear(in_features=2048, out_features=2048, bias=True)     (4): ELU(alpha=1.0)     (5): Linear(in_features=2048, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM network for arrythmia detection. This model initialy was designed to deal with 2D images. It was adapted to 1D time series.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=ZhengZhenyu_Classifier(256, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Zheng, Z., Chen, Z., Hu, F., Zhu, J., Tang, Q., & Liang, Y. (2020). An automatic diagnosis of arrhythmias using a combination of CNN and LSTM technology. Electronics, 9(1), 121.

TSFEDL.models_pytorch.WangKejun(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = WangKejun_Classifier(   (module): Sequential(     (0): Flatten(start_dim=1, end_dim=-1)     (1): Linear(in_features=256, out_features=2048, bias=True)     (2): ELU(alpha=1.0)     (3): Dropout(p=0.5, inplace=False)     (4): Linear(in_features=2048, out_features=2048, bias=True)     (5): ELU(alpha=1.0)     (6): Linear(in_features=2048, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN 1D-LSTM

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=WangKejun_Classifier(256, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Wang, Kejun, Xiaoxia Qi, and Hongda Liu. “Photovoltaic power forecasting based LSTM-Convolutional Network.” Energy 189 (2019): 116225.

TSFEDL.models_pytorch.ChenChen(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = ChenChen_Classifier(   (module): Sequential(     (0): Flatten(start_dim=1, end_dim=-1)     (1): Linear(in_features=64, out_features=5, bias=True)     (2): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model for arrythmia classification.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=ChenChen_Classifier(64, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Chen, Chen, et al. “Automated arrhythmia classification based on a combination network of CNN and LSTM.” Biomedical Signal Processing and Control 57 (2020): 101819.

TSFEDL.models_pytorch.KimTaeYoung(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = KimTaeYoung_Classifier(   (module): Sequential(     (0): Linear(in_features=64, out_features=32, bias=True)     (1): ReLU()     (2): Linear(in_features=32, out_features=5, bias=True)     (3): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model for arrythmia classification.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=KimTaeYoung_Classifier(64, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Kim, Tae-Young, and Sung-Bae Cho. “Predicting residential energy consumption using CNN-LSTM neural networks.” Energy 182 (2019): 72-81.

Notes

In the original paper, the time-series is windowed. Therefore, a TimeDistributed layer is employed before the LSTM to traverse all the generated windows. Here, we do not implement this as it is problem-specific. Please note that if you need this layer then you should add it manually.

TSFEDL.models_pytorch.GenMinxing(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = GenMinxing_Classifier(   (module): Sequential(     (0): Flatten(start_dim=1, end_dim=-1)     (1): Linear(in_features=80, out_features=5, bias=True)     (2): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model for arrythmia classification.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=GenMinxing_Classifier(80, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Geng, Minxing, et al. “Epileptic Seizure Detection Based on Stockwell Transform and Bidirectional Long Short-Term Memory.” IEEE Transactions on Neural Systems and Rehabilitation Engineering 28.3 (2020): 573-580.

TSFEDL.models_pytorch.FuJiangmeng(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = FuJiangmeng_Classifier(   (module): Sequential(     (0): Linear(in_features=256, out_features=128, bias=True)     (1): Tanh()     (2): Dropout(p=0.3, inplace=False)     (3): Linear(in_features=128, out_features=5, bias=True)     (4): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model for arrythmia classification.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=FuJiangmeng_Classifier(256, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Fu, Jiangmeng, et al. “A hybrid CNN-LSTM model based actuator fault diagnosis for six-rotor UAVs.” 2019 Chinese Control And Decision Conference (CCDC). IEEE, 2019.

TSFEDL.models_pytorch.ShiHaotian(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = None, loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model for arrythmia classification.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=None) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Shi, Haotian, et al. “Automated heartbeat classification based on deep neural network with multiple input layers.” Knowledge-Based Systems 188 (2020): 105036.

TSFEDL.models_pytorch.HuangMeiLing(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = HuangMeiLing_Classifier(   (module): Sequential(     (0): Flatten(start_dim=1, end_dim=-1)     (1): Dropout(p=0.5, inplace=False)     (2): Linear(in_features=81, out_features=512, bias=True)     (3): ReLU()     (4): Linear(in_features=512, out_features=256, bias=True)     (5): ReLU()     (6): Linear(in_features=256, out_features=5, bias=True)     (7): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN model, employed for 2-D images of ECG data. This model is adapted for 1-D time series

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=None) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Huang, Mei-Ling, and Yan-Sheng Wu. “Classification of atrial fibrillation and normal sinus rhythm based on convolutional neural network.” Biomedical Engineering Letters (2020): 1-11.

TSFEDL.models_pytorch.LihOhShu(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = LiOhShu_Classifier(   (module): Sequential(     (0): Linear(in_features=10, out_features=8, bias=True)     (1): ReLU()     (2): Dropout(p=0.5, inplace=False)     (3): Linear(in_features=8, out_features=8, bias=True)     (4): ReLU()     (5): Dropout(p=0.5, inplace=False)     (6): Linear(in_features=8, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=LiOhShu_Classifier(10, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Lih, Oh Shu, et al. “Comprehensive electrocardiographic diagnosis based on deep learning.” Artificial Intelligence in Medicine 103 (2020): 101789.

TSFEDL.models_pytorch.GaoJunLi(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = GaoJunLi_Classifier(   (module): Sequential(     (0): Linear(in_features=64, out_features=32, bias=True)     (1): ReLU()     (2): Linear(in_features=32, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

LSTM network

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=GaoJunLi_Classifier(64, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Gao, Junli, et al. “An Effective LSTM Recurrent Network to Detect Arrhythmia on Imbalanced ECG Dataset.” Journal of healthcare engineering 2019 (2019).

TSFEDL.models_pytorch.WeiXiaoyan(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = WeiXiaoyan_Classifier(   (module): Sequential(     (0): Linear(in_features=512, out_features=1024, bias=True)     (1): ReLU()     (2): Linear(in_features=1024, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM model employed for 2-D images of ECG data. This model is adapted for 1-D time series.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=WeiXiaoyan_Classifier(512, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Wei, Xiaoyan, et al. “Early prediction of epileptic seizures using a long-term recurrent convolutional network.” Journal of neuroscience methods 327 (2019): 108395.

TSFEDL.models_pytorch.KongZhengmin(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = KongZhengmin_Classifier(   (module): Sequential(     (0): Linear(in_features=64, out_features=50, bias=True)     (1): ReLU()     (2): Linear(in_features=50, out_features=50, bias=True)     (3): ReLU()     (4): Linear(in_features=50, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN+LSTM

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=KongZhengmin_Classifier(64, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Kong, Zhengmin, et al. “Convolution and Long Short-Term Memory Hybrid Deep Neural Networks for Remaining Useful Life Prognostics.” Applied Sciences 9.19 (2019): 4156.

TSFEDL.models_pytorch.YildirimOzal(input_shape: ~typing.Tuple[int, int], train_autoencoder: bool = True, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = None, loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CAE-LSTM

Parameters:
  • input_shape (Tuple[int, int]) – Shape of the input tensors (number of channels, sequence length)

  • train_autoencoder (bool, defaults=True) – This parameter controls wether to train the autoencoder or the classifier

  • top_module (nn.Module) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

  • autoenconder (LightningModule) – A pyTorch Lightning Module instance with the autoencoder.

  • encoder (LightningModule) – A pyTorch Lightning Module instance with the encoder.

  • model (LightningModule) – A pyTorch Lightning Module instance with the classifier.

References

Yildirim, Ozal, et al. “A new approach for arrhythmia classification using deep coded features and LSTM networks.” Computer methods and programs in biomedicine 176 (2019): 121-133.

TSFEDL.models_pytorch.CaiWenjuan(in_features: int, reduction_ratio: float = 0.6, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = Sequential(   (0): Linear(in_features=67, out_features=5, bias=True) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

DDNN network presented in:

Parameters:
  • in_features (int) – Number of features of the input tensors

  • reduction_ratio (float, defaults=0.6) – This parameter controls the reduction of the dense transition block

  • top_module (nn.Module) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Cai, Wenjuan, et al. “Accurate detection of atrial fibrillation from 12-lead ECG using deep neural network.” Computers in biology and medicine 116 (2020): 103378.

TSFEDL.models_pytorch.HtetMyetLynn(in_features: int, use_rnn: ~typing.Optional[str] = 'gru', top_module: ~typing.Optional[~torch.nn.modules.module.Module] = Sequential(   (0): Linear(in_features=80, out_features=5, bias=True) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

Hybrid CNN+Bidirectional RNN

Parameters:
  • in_features (int) – Number of features of the input tensors

  • use_rnn (str, ["gru", "lstm", None], defaults="gru") – This parameter controls wether to use RNN layers and what type to use

  • top_module (nn.Module) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Lynn, H. M., Pan, S. B., & Kim, P. (2019). A deep bidirectional GRU network model for biometric electrocardiogram classification based on recurrent neural networks. IEEE Access, 7, 145395-145405.

TSFEDL.models_pytorch.ZhangJin(in_features: int, decrease_ratio: int = 2, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = ZhangJin_Classifier(   (linear): Sequential(     (0): Linear(in_features=24, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

A CNN+Bi-Directional GRU with a spatio-temporal attention mechanism.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • decrease_ratio (int, defaults=2) – This parameter controls the decrease ratio of the spatial attention block

  • top_module (nn.Module, defaults=ZhangJin_Classifier(24, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Zhang, J., Liu, A., Gao, M., Chen, X., Zhang, X., & Chen, X. (2020). ECG-based multi-class arrhythmia detection using spatio-temporal attention-based convolutional recurrent neural network. Artificial Intelligence in Medicine, 106, 101856.

TSFEDL.models_pytorch.YaoQihang(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = YaoQihangClassifier(   (module): Sequential(     (0): Linear(in_features=32, out_features=32, bias=True)     (1): Tanh()     (2): Linear(in_features=32, out_features=5, bias=True)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = None, metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

Attention-based time-incremental convolutional neural network (ATI-CNN)

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=YaoQihangClassifier(32, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Yao, Q., Wang, R., Fan, X., Liu, J., & Li, Y. (2020). Multi-class Arrhythmia detection from 12-lead varied-length ECG using Attention-based Time-Incremental Convolutional Neural Network. Information Fusion, 53, 174-182.

TSFEDL.models_pytorch.YiboGao(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = YiboGaoClassifier(   (module): Sequential(     (0): Flatten(start_dim=1, end_dim=-1)     (1): Dropout(p=0.7, inplace=False)     (2): Linear(in_features=384, out_features=100, bias=True)     (3): ReLU()     (4): Dropout(p=0.7, inplace=False)     (5): Linear(in_features=100, out_features=5, bias=True)     (6): Softmax(dim=1)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = <function en_loss>, metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

CNN using RTA blocks for end-to-end attrial fibrilation detection.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=YiboGaoClassifier(384, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Gao, Y., Wang, H., & Liu, Z. (2021). An end-to-end atrial fibrillation detection by a novel residual-based temporal attention convolutional neural network with exponential nonlinearity loss. Knowledge-Based Systems, 212, 106589.

Notes

Code adapted from the original implementation available at:

https://github.com/o00O00o/RTA-CNN

TSFEDL.models_pytorch.SharPar(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = SharPar_Classifier(   (module): Sequential(     (0): Linear(in_features=16, out_features=5, bias=True)     (1): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

A 1-layer CNN + LSTM model. Originally proposed for depression detection.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=SharPar_Classifier(256, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Sharma, G., Parashar, A., & Joshi, A. M. (2021). DepHNN: a novel hybrid neural network for electroencephalogram (EEG)-based screening of depression. Biomedical signal processing and control, 66, 102393.

TSFEDL.models_pytorch.DaiXiLi(in_features: int, top_module: ~typing.Optional[~torch.nn.modules.module.Module] = DaiXiLi_Classifier(   (module): Sequential(     (0): Linear(in_features=2048, out_features=5, bias=True)     (1): Softmax(dim=None)   ) ), loss: ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor] = CrossEntropyLoss(), metrics: ~typing.Dict[str, ~typing.Callable[[~torch.Tensor, ~torch.Tensor], ~torch.Tensor]] = None, optimizer: ~torch.optim.optimizer.Optimizer = <class 'torch.optim.adam.Adam'>, **kwargs)[source]

A 1-layer CNN + LSTM model. Originally proposed for depression detection.

Parameters:
  • in_features (int) – Number of features of the input tensors

  • top_module (nn.Module, defaults=DaiXiLi_Classifier(256, 5)) – The optional nn.Module to be used as additional top layers.

  • loss (Callable[[torch.Tensor, torch.Tensor], torch.Tensor]) – The loss function to use. It should accept two Tensors as inputs (predictions, targets) and return a Tensor with the loss.

  • metrics (Dict[str, Callable[[torch.Tensor, torch.Tensor], torch.Tensor]]) – Dictionary with the name of the metric and a function to compute the metric from two tensors, prediction and true labels.

  • optimizer (torch.optim.Optimizer) – The pyTorch Optimizer to use. Note that this must be only the class type and not an instance of the class!!

  • **kwargs (dict) – A dictionary with the parameters of the optimizer.

Returns:

A pyTorch Lightning Module instance.

Return type:

LightningModule

References

Sharma, G., Parashar, A., & Joshi, A. M. (2021). DepHNN: a novel hybrid neural network for electroencephalogram (EEG)-based screening of depression. Biomedical signal processing and control, 66, 102393.