Skip to content

EEG-GAN Examples

You can run the three main functions either from terminal or as a function within your script. Below, we will provide some examples of arguments that demonstrate both.

Train GAN Examples

Select Training Dataset You can direct the GAN to train on specific datasets using the path_dataset argument.

From terminal:
python Train_Gan.py path_dataset=data\my_data.csv

As a function:
from eeggan import train_gan

argv = dict(
  path_dataset = "data\my_data.csv"
)

train_gan(argv)
Number of Epochs You can vary the number of epochs that the GAN is trained on with the n_epochs parameter.

From terminal:
python Train_Gan.py n_epochs=8000

As a function:
from eeggan import train_gan

argv = dict(
  n_epochs = 8000
)

train_gan(argv)
Continue Training a GAN You can continue training a GAN using the train_gan and (optionally) path_checkpoint arguments. Not including the path_checkpoint argument will default to training a model checkpoint.pt

From terminal:
python Train_Gan.py train_gan path_checkpoint=my_model.pt

As a function:
from eeggan import train_gan

argv = dict(
  path_checkpoint = "my_model.pt"
)

train_gan(argv)
Training on GPU You can use your GPU rather than CPU to train the GAN using the ddp parameter.

From terminal:
python Train_Gan.py ddp

As a function:
from eeggan import train_gan

argv = dict(
  ddp = True
)

train_gan(argv)
Integrated GAN Training We can use multiple arguments together to train our GAN, for example:
 On GPUs ddp
 On our dataset path_dataset=data\my_data.csv
 For 8000 epochs n_epochs=8000

From terminal:
python Train_Gan.py ddp path_dataset=data\my_data.csv n_epochs=8000

As a function:
from eeggan import train_gan

argv = dict(
  ddp = True,
  path_dataset = "data\my_data.csv",
  n_epochs = 8000
)

train_gan(argv)

Visualize GAN Examples

Select GAN Model First, you must tell the function what type of data it will be analyzing using the checkpoint, experiment, or csv_file arguments. We will use checkpoint, which is used for GAN models.

You can visualize a specific GAN using the file and the training_file arguments.

From terminal:
python Visualize_Gan.py checkpoint file=my_GAN.pt training_file=data\my_data.csv

As a function:
from eeggan import visualize_gan

argv = dict(
  checkpoint = True,
  file = "my_GAN.pt",
  training_file = "data\my_data.csv"
)

visualize_gan(argv)
Visualize GAN Model Losses First, you must tell the function what type of data it will be analyzing using the checkpoint, experiment, or csv_file arguments. We will use checkpoint, which is used for GAN models.

You can visualize GAN model losses using the plot_losses argument.

From terminal:
python Visualize_Gan.py checkpoint plot_losses

As a function:
from eeggan import visualize_gan

argv = dict(
  checkpoint = True,
  plot_losses = True
)

visualize_gan(argv)
Visualize Averaged GAN Samples First, you must tell the function what type of data it will be analyzing using the checkpoint, experiment, or csv_file arguments. We will use checkpoint, which is used for GAN models.

You can visualize a grand-average of data (across conditions) using the averaged argument.

From terminal:
python Visualize_Gan.py checkpoint averaged

As a function:
from eeggan import visualize_gan

argv = dict(
  checkpoint = True,
  averaged = True
)

visualize_gan(argv)
Integrated GAN Visualization First, you must tell the function what type of data it will be analyzing using the checkpoint, experiment, or csv_file arguments. We will use checkpoint, which is used for GAN models.

We can use multiple arguments together to visualize our data, for example:
 On a GAN checkpoint
 Plot losses plot_losses
 Selecting a GAN file=gansEEGModel.pt

From terminal:
python Visualize_Gan.py checkpoint plot_losses file=gansEEGModel.pt

As a function:
from eeggan import visualize_gan

argv = dict(
  checkpoint = True,
  plot_losses = True,
  file = "gansEEGModel.pt"
)

visualize_gan(argv)

Generate Samples Examples

Select GAN Model You can generate samples from a specific GAN using the file argument.

From terminal:
python Generate_Samples.py file=my_GAN.pt

As a function:
from eeggan import generate_samples

argv = dict(
  file = "my_GAN.pt"
)

generate_samples(argv)
Set Generated Samples Save Name You can declare the path and name of the saved generated samples file using the path_samples argument.

From terminal:
python Generate_Samples.py path_samples=generated_samples\my_samples.csv

As a function:
from eeggan import generate_samples

argv = dict(
  path_samples = "generated_samples\my_samples.csv"
)

generate_samples(argv)
Set Number of Samples to Generate You can set the total number of samples to generate (which will be split equally across conditions) using the num_samples_total argument.

From terminal:
python Generate_Samples.py num_samples_total=10000

As a function:
from eeggan import generate_samples

argv = dict(
  num_samples_total = 10000
)

generate_samples(argv)
Set Number of Samples to Generate in Parallel You can set the number of samples that will be generated in parallel using the num_samples_parallel argument.

From terminal:
python Generate_Samples.py num_samples_parallel=1000

As a function:
from eeggan import generate_samples

argv = dict(
  num_samples_parallel = 1000
)

generate_samples(argv)
Integrated Generate Samples We can use multiple arguments together to generate samples, for example:
 On our model file=my_GAN.pt
 With a saved filename path_samples=generated_samples\my_samples.csv
 Generating 10,000 samples num_samples_total=10000
 At a rate of 1,000 at a time num_samples_parallel=1000

From terminal:
python Generate_Samples.py file=my_GAN.pt path_samples=generated_samples\my_samples.csv num_samples_total=10000 num_samples_parallel=1000

As a function:
from eeggan import generate_samples

argv = dict(
  file = "my_GAN.pt",
  path_samples = "generated_samples\my_samples.csv",
  num_samples_total = 10000,
  num_samples_parallel = 1000
)

generate_samples(argv)