Shortcuts

BDecoder

class torcheeg.models.BDecoder(in_channels: int = 64, out_channels: int = 4, grid_size: Tuple[int, int] = (9, 9))[source][source]

The variational autoencoder consists of two parts, an encoder, and a decoder. The encoder compresses the input into the latent space. The decoder receives as input the information sampled from the latent space and produces it as similar as possible to ground truth. The latent vector should approach the gaussian distribution supervised by KL divergence based on the variation trick. This class implement the decoder part.

encoder = BEncoder(in_channels=4)
decoder = BDecoder(in_channels=64, out_channels=4)
mock_eeg = torch.randn(1, 4, 9, 9)
mu, logvar = encoder(mock_eeg)
std = torch.exp(0.5 * logvar)
eps = torch.randn_like(std)
z = eps * std + mu
fake_X = decoder(z)
Parameters:
  • in_channels (int) – The input feature dimension (of noise vectors). (default: 64)

  • 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))

forward(x: Tensor)[source][source]
Parameters:

x (torch.Tensor) – Given the mean and standard deviation vectors, the feature vector z obtained using the reparameterization technique. The shapes of the feature vector should be [n, 64]. Here, n corresponds to the batch size, and 64 corresponds to in_channels.

Returns:

the decoded results, which should have the same shape as the input noise, i.e., [n, 4, 9, 9]. Here, n corresponds to the batch size, 4 corresponds to in_channels, and (9, 9) corresponds to 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