Shortcuts

BCGenerator

class torcheeg.models.BCGenerator(in_channels: int = 128, out_channels: int = 4, grid_size: Tuple[int, int] = (9, 9), num_classes: int = 3)[source][source]

GAN-based methods formulate a zero-sum game between the generator and the discriminator. The generator is optimized to generate simulation samples that are indistinguishable by the discriminator, and the discriminator is optimized to discriminate false samples generated by the generator. This class provide a baseline implementation for the generator. In particular, the expected labels are additionally provided to guide the generator to generate samples of the specified class from the random noise.

import torch

from torcheeg.models.gan.bcgan import BCGenerator

g_model = BCGenerator(in_channels=128, num_classes=3)
z = torch.normal(mean=0, std=1, size=(1, 128))
y = torch.randint(low=0, high=3, size=(1,))
fake_X = g_model(z, y)
Parameters:
  • in_channels (int) – The input feature dimension (of noise vectors). (default: 128)

  • out_channels (int) – The generated 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. (default: 2)

forward(x: Tensor, y: Tensor)[source][source]
Parameters:
  • x (torch.Tensor) – a random vector, the ideal input shape is [n, 128]. Here, n corresponds to the batch size, and 128 corresponds to in_channels.

  • y (torch.Tensor) – Category labels (int) for a batch of samples The shape should be [n,]. Here, n corresponds to the batch size.

Returns:

the generated fake EEG signals. Here, 4 corresponds to the out_channels, and (9, 9) corresponds to the grid_size.

Return type:

torch.Tensor[n, 4, 9, 9]

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