TCNet¶
- class torcheeg.models.TCNet(num_classes: int = 2, num_electrodes: int = 22, layers: int = 2, tcn_kernel_size: int = 4, hid_channels: int = 12, tcn_dropout: float = 0.3, activation: str = 'relu', F1: int = 8, D: int = 2, eegnet_kernel_size: int = 32, eegnet_dropout: float = 0.2)[source][source]¶
A temporal convolutional network. For more details, please refer to the following information.
Paper: Ingolfsson T M, Hersche M, Wang X, et al. EEG-TCNet: An accurate temporal convolutional network for embedded motor-imagery brain–machine interfaces[C]//2020 IEEE International Conference on Systems, Man, and Cybernetics (SMC). IEEE, 2020: 2958-2965.
Related Project: https://github.com/iis-eth-zurich/eeg-tcnet
Below is a quick start example:
from torcheeg.models import TCNet model = TCNet(num_classes=4, num_electrodes=22, F1=8, D=2) # batch_size, num_electrodes, time_points x = torch.randn(32, 22, 1000) model(x)
- Parameters:
num_classes (int) – The number of classes to classify. (default:
2)num_electrodes (int) – The number of EEG channels. (default:
22)layers (int) – Number of TCN layers in the network. (default:
2)tcn_kernel_size (int) – Kernel size for the TCN convolutional layers. (default:
4)hid_channels (int) – Number of hidden channels in TCN blocks. (default:
12)tcn_dropout (float) – Dropout rate for TCN layers. (default:
0.3)activation (str) – Activation function to use in TCN blocks. (default:
'relu')F1 (int) – Number of temporal filters in EEGNet. (default:
8)D (int) – Multiplication factor for number of spatial filters in EEGNet. (default:
2)eegnet_kernel_size (int) – Kernel size for EEGNet’s temporal convolution. (default:
32)eegnet_dropout (float) – Dropout rate for EEGNet layers. (default:
0.2)
- forward(x)[source][source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.