Shortcuts

GRU

class torcheeg.models.GRU(num_electrodes: int = 32, hid_channels: int = 64, num_classes: int = 2)[source][source]

A simple but effective gate recurrent unit (GRU) network structure from the book of Zhang et al. For more details, please refer to the following information.

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

from torcheeg.datasets import DEAPDataset
from torcheeg import transforms
from torcheeg.models import GRU
from torch.utils.data import DataLoader

dataset = DEAPDataset(root_path='./data_preprocessed_python',
                      online_transform=transforms.ToTensor(),
                      label_transform=transforms.Compose([
                          transforms.Select('valence'),
                          transforms.Binary(5.0),
                      ]))

model = GRU(num_electrodes=32, hid_channels=64, num_classes=2)

x, y = next(iter(DataLoader(dataset, batch_size=64)))
model(x)
Parameters:
  • num_electrodes (int) – The number of electrodes, i.e., \(C\) in the paper. (default: 32)

  • hid_channels (int) – The number of hidden nodes in the GRU layers and the fully connected layer. (default: 64)

  • 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, 32, 128]. Here, n corresponds to the batch size, 32 corresponds to num_electrodes, and 128 corresponds to the number of data points included in the input EEG chunk.

Returns:

the predicted probability that the samples belong to the classes.

Return type:

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

Read the Docs v: latest
Versions
latest
stable
v1.1.1
v1.1.0
v1.0.11
v1.0.10
v1.0.9
v1.0.8.post1
v1.0.8
v1.0.7
v1.0.6
v1.0.4
v1.0.3
v1.0.2
v1.0.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

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