DGCNN¶
- class torcheeg.models.DGCNN(in_channels: int = 5, num_electrodes: int = 62, num_layers: int = 2, hid_channels: int = 32, num_classes: int = 2)[source][source]¶
Dynamical Graph Convolutional Neural Networks (DGCNN). For more details, please refer to the following information.
Paper: Song T, Zheng W, Song P, et al. EEG emotion recognition using dynamical graph convolutional neural networks[J]. IEEE Transactions on Affective Computing, 2018, 11(3): 532-541.
Related Project: https://github.com/xueyunlong12589/DGCNN
Below is a recommended suite for use in emotion recognition tasks:
from torcheeg.models import DGCNN from torcheeg.datasets import SEEDDataset from torcheeg import transforms dataset = SEEDDataset(root_path='./Preprocessed_EEG', offline_transform=transforms.BandDifferentialEntropy(band_dict={ "delta": [1, 4], "theta": [4, 8], "alpha": [8, 14], "beta": [14, 31], "gamma": [31, 49] }), online_transform=transforms.Compose([ transforms.ToTensor() ]), label_transform=transforms.Compose([ transforms.Select('emotion'), transforms.Lambda(lambda x: x + 1) ])) model = DGCNN(in_channels=5, num_electrodes=62, hid_channels=32, num_layers=2, num_classes=2) x, y = next(iter(DataLoader(dataset, batch_size=64))) model(x)
- Parameters:
in_channels (int) – The feature dimension of each electrode. (default:
5
)num_electrodes (int) – The number of electrodes. (default:
62
)num_layers (int) – The number of graph convolutional layers. (default:
2
)hid_channels (int) – The number of hidden nodes in the first fully connected layer. (default:
32
)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, 62, 5]
. Here,n
corresponds to the batch size,62
corresponds tonum_electrodes
, and5
corresponds toin_channels
.- Returns:
the predicted probability that the samples belong to the classes.
- Return type:
torch.Tensor[number of sample, number of classes]