braindecode.models.TCN#

class braindecode.models.TCN(n_chans=None, n_outputs=None, n_blocks=None, n_filters=None, kernel_size=None, drop_prob=None, chs_info=None, n_times=None, input_window_seconds=None, sfreq=None, n_in_chans=None, add_log_softmax=False)[source]#

Temporal Convolutional Network (TCN) from Bai et al 2018.

See [Bai2018] for details.

Code adapted from locuslab/TCN

Parameters:
  • n_chans (int) – Number of EEG channels.

  • n_outputs (int) – Number of outputs of the model. This is the number of classes in the case of classification.

  • n_blocks (int) – number of temporal blocks in the network

  • n_filters (int) – number of output filters of each convolution

  • kernel_size (int) – kernel size of the convolutions

  • drop_prob (float) – dropout probability

  • chs_info (list of dict) – Information about each individual EEG channel. This should be filled with info["chs"]. Refer to mne.Info for more details.

  • n_times (int) – Number of time samples of the input window.

  • input_window_seconds (float) – Length of the input window in seconds.

  • sfreq (float) – Sampling frequency of the EEG recordings.

  • n_in_chans (int) – Alias for n_chans.

  • add_log_softmax (bool) – Whether to use log-softmax non-linearity as the output function. LogSoftmax final layer will be removed in the future. Please adjust your loss function accordingly (e.g. CrossEntropyLoss)! Check the documentation of the torch.nn loss functions: https://pytorch.org/docs/stable/nn.html#loss-functions.

Raises:
  • ValueError – If some input signal-related parameters are not specified: and can not be inferred.

  • FutureWarning – If add_log_softmax is True, since LogSoftmax final layer: will be removed in the future.

Notes

If some input signal-related parameters are not specified, there will be an attempt to infer them from the other parameters.

References

[Bai2018]

Bai, S., Kolter, J. Z., & Koltun, V. (2018). An empirical evaluation of generic convolutional and recurrent networks for sequence modeling. arXiv preprint arXiv:1803.01271.

Methods

forward(x)[source]#

Forward pass.

Parameters:

x (torch.Tensor) – Batch of EEG windows of shape (batch_size, n_channels, n_times).