ShallowConvNet#

class dpeeg.models.ShallowConvNet.ShallowConvNet(nCh: int, nTime: int, nCls: int, F: int = 40, C: int = 14, P: int = 35, S: int = 7, dropout: float = 0.5)[source]#

Deep Learning With Convolutional Neural Networks for EEG Decoding and Visualization (ShallowConvNet).

Shallow ConvNet [1], inspired by the FBCSP pipeline, is specifically tailored to decode band power features. The transformations performed by the shallow ConvNet are similar to the transformations of FBCSP. Concretely, the first two layers of the shallow ConvNet perform a temporal convolution and a spatial filter, as in the deep ConvNet. These steps are analogous to the bandpass and CSP spatial filter steps in FBCSP. In contrast to the deep ConvNet, the temporal convolution of the shallow ConvNet had a larger kernel size, allowing a larger range of transformations in this layer (smaller kernel sizes for the shallow ConvNet led to lower accuracies in preliminary experiments on the training set). After the temporal convolution and the spatial filter of the shallow ConvNet, a squaring nonlinearity, a mean pooling layer and a logarithmic activation function followed; together these steps are analogous to the trial log-variance computation in FBCSP. In contrast to FBCSP, the shallow ConvNet embeds all the computational steps in a single network, and thus all steps can be optimized jointly. Also, due to having several pooling regions within one trial, the shallow ConvNet can learn a temporal structure of the band power changes within the trial.

Parameters:
  • nCh (int) – Number of electrode channels.

  • nTime (int) – Number of data sampling points. For example, a 4-second data input with a sampling rate of 250 Hz is 1000.

  • nCls (int) – Number of classification categories.

  • F (int) – The number of convolution channels.

  • C (int) – Temporal convolution kernel size.

  • P (int) – Pooling kernel size.

  • S (int) – Pooling layer stride size.

  • dropout (float) – Dropout rate.

References

forward(x)[source]#

Forward pass function that processes the input EEG data and produces the decoded results.

Parameters:

x (Tensor) – Input EEG data, shape (batch_size, bands, nCh, nTime).

Returns:

cls_prob – Predicted class probability, shape (batch_size, nCls).

Return type:

Tensor