FBCCNN¶
- class torcheeg.models.FBCCNN(in_channels: int = 4, grid_size: Tuple[int, int] = (9, 9), num_classes: int = 2)[source][source]¶
Frequency Band Correlation Convolutional Neural Network (FBCCNN). For more details, please refer to the following information.
Paper: Pan B, Zheng W. Emotion Recognition Based on EEG Using Generative Adversarial Nets and Convolutional Neural Network[J]. Computational and Mathematical Methods in Medicine, 2021.
Below is a recommended suite for use in emotion recognition tasks:
from torcheeg.datasets import DEAPDataset from torcheeg import transforms from torcheeg.datasets.constants import DEAP_CHANNEL_LOCATION_DICT from torcheeg.models import FBCCNN from torch.utils.data import DataLoader dataset = DEAPDataset(root_path='./data_preprocessed_python', online_transform=transforms.Compose([ transforms.BandPowerSpectralDensity(), transforms.ToGrid(DEAP_CHANNEL_LOCATION_DICT) ]), label_transform=transforms.Compose([ transforms.Select('valence'), transforms.Binary(5.0), ])) model = FBCCNN(num_classes=2, in_channels=4, grid_size=(9, 9)) x, y = next(iter(DataLoader(dataset, batch_size=64))) model(x)
- Parameters:
in_channels (int) – The feature dimension of each electrode, i.e., \(N\) in the paper. (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
)
- forward(x: Tensor) Tensor [source][source]¶
- Parameters:
x (torch.Tensor) – EEG signal representation, the ideal input shape is
[n, 4, 9, 9]
. Here,n
corresponds to the batch size,4
corresponds 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]