Shortcuts

TSCeption

class torcheeg.models.TSCeption(num_electrodes: int = 28, num_T: int = 15, num_S: int = 15, in_channels: int = 1, hid_channels: int = 32, num_classes: int = 2, sampling_rate: int = 128, dropout: float = 0.5)[source][source]

Continuous Convolutional Neural Network (CCNN). For more details, please refer to the following information.

Below is a recommended suite for use in emotion recognition tasks:

dataset = DEAPDataset(io_path=f'./deap',
            root_path='./data_preprocessed_python',
            chunk_size=512,
            num_baseline=1,
            baseline_chunk_size=512,
            offline_transform=transforms.Compose([
                PickElectrode(PickElectrode.to_index_list(
                ['FP1', 'AF3', 'F3', 'F7',
                'FC5', 'FC1', 'C3', 'T7',
                'CP5', 'CP1', 'P3', 'P7',
                'PO3','O1', 'FP2', 'AF4',
                'F4', 'F8', 'FC6', 'FC2',
                'C4', 'T8', 'CP6', 'CP2',
                'P4', 'P8', 'PO4', 'O2'], DEAP_CHANNEL_LIST)),
                transforms.To2d()
            ]),
            online_transform=transforms.ToTensor(),
            label_transform=transforms.Compose([
                transforms.Select('valence'),
                transforms.Binary(5.0),
            ]))
model = TSCeption(num_classes=2,
                  num_electrodes=28,
                  sampling_rate=128,
                  num_T=15,
                  num_S=15,
                  hid_channels=32,
                  dropout=0.5)
Parameters
  • num_electrodes (int) – The number of electrodes. (defualt: 28)

  • num_T (int) – The number of multi-scale 1D temporal kernels in the dynamic temporal layer, i.e., \(T\) kernels in the paper. (defualt: 15)

  • num_S (int) – The number of multi-scale 1D spatial kernels in the asymmetric spatial layer. (defualt: 15)

  • in_channels (int) – The number of channels of the signal corresponding to each electrode. If the original signal is used as input, in_channels is set to 1; if the original signal is split into multiple sub-bands, in_channels is set to the number of bands. (defualt: 1)

  • hid_channels (int) – The number of hidden nodes in the first fully connected layer. (defualt: 32)

  • num_classes (int) – The number of classes to predict. (defualt: 2)

  • sampling_rate (int) – The sampling rate of the EEG signals, i.e., \(f_s\) in the paper. (defualt: 128)

  • dropout (float) – Probability of an element to be zeroed in the dropout layers. (defualt: 0.5)

forward(x: Tensor) Tensor[source][source]
Parameters

x (torch.Tensor) – EEG signal representation, the ideal input shape is [n, 1, 28, 512]. Here, n corresponds to the batch size, 1 corresponds to number of channels for convolution, 28 corresponds to num_electrodes, and 512 corresponds to the input dimension for each electrode.

Returns

the predicted probability that the samples belong to the classes.

Return type

torch.Tensor[number of sample, number of classes]

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources