CSPNet¶
- class torcheeg.models.CSPNet(chunk_size: int = 1750, num_electrodes: int = 22, num_classes: int = 5, dropout: float = 0.5, num_filters_t: float = 20, filter_size_t: float = 25, num_filters_s: float = 2, filter_size_s: float = -1, pool_size_1: float = 100, pool_stride_1: float = 25)[source][source]¶
CSP-empowered neural network (CSP-Net). For more details, please refer to the following information.
Paper: Jiang X, Meng L, Chen X, et al. CSP-Net: Common spatial pattern empowered neural networks for EEG-based motor imagery classification[J]. Knowledge-Based Systems, 2024, 305: 112668.
URL: https://www.sciencedirect.com/science/article/pii/S0950705124013029
Below is a quick start example:
from torcheeg.models import CSPNet model = CSPNet(chunk_size=1750, num_electrodes=22, num_classes=5, num_filters_t=20, filter_size_t=25) # batch_size, num_electrodes, n_electrodes, chunk_size x = torch.randn(10, 1, 22, 1750) model(x)
- Parameters:
chunk_size (int) – Number of data points included in each EEG chunk. (default:
1750)num_electrodes (int) – The number of electrodes, i.e., number of channels. (default:
22)num_classes (int) – The number of classes to predict. (default:
5)dropout (float) – Dropout rate. (default:
0.5)num_filters_t (int) – The number of temporal filters. (default:
20)filter_size_t (int) – The size of temporal filters. Must be smaller than chunk_size. (default:
25)num_filters_s (int) – The number of spatial filters per temporal filter. (default:
2)filter_size_s (int) – The size of spatial filters. If less than or equal to 0, it will be set to num_electrodes. (default:
-1)pool_size_1 (int) – The size of the average pooling layer. (default:
100)pool_stride_1 (int) – The stride of the average pooling layer. (default:
25)
- 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.