CCNN¶
- class torcheeg.models.CCNN(in_channels: int = 4, grid_size: Tuple[int, int] = (9, 9), num_classes: int = 2, dropout: float = 0.5)[source][source]¶
Continuous Convolutional Neural Network (CCNN). For more details, please refer to the following information.
Paper: Yang Y, Wu Q, Fu Y, et al. Continuous convolutional neural network with 3D input for EEG-based emotion recognition[C]//International Conference on Neural Information Processing. Springer, Cham, 2018: 433-443.
URL: https://link.springer.com/chapter/10.1007/978-3-030-04239-4_39
Related Project: https://github.com/ynulonger/DE_CNN
Below is a recommended suite for use in emotion recognition tasks:
dataset = DEAPDataset(io_path=f'./deap', root_path='./data_preprocessed_python', offline_transform=transforms.Compose([ transforms.BandDifferentialEntropy(), transforms.ToGrid(DEAP_CHANNEL_LOCATION_DICT) ]), online_transform=transforms.ToTensor(), label_transform=transforms.Compose([ transforms.Select('valence'), transforms.Binary(5.0), ])) model = CCNN(num_classes=2, in_channels=4, grid_size=(9, 9))
- Parameters:
in_channels (int) – The feature dimension of each electrode. (default:
4)grid_size (tuple) – Spatial dimensions of grid-like EEG representation. (default:
(9, 9))num_classes (int) – The number of classes to predict. (default:
2)dropout (float) – Probability of an element to be zeroed in the dropout layers. (default:
0.25)
- forward(x: Tensor) Tensor[source][source]¶
- Parameters:
x (torch.Tensor) – EEG signal representation, the ideal input shape is
[n, 4, 9, 9]. Here,ncorresponds to the batch size,4corresponds toin_channels, and(9, 9)corresponds togrid_size.- Returns:
the predicted probability that the samples belong to the classes.
- Return type:
torch.Tensor[number of sample, number of classes]