Skip to content

06. Configuring Training Parameters

Renan Siqueira Antonio edited this page Oct 6, 2023 · 1 revision

Introduction

Properly configuring training parameters is essential for optimal model training.

These parameters influence how the model learns and the quality of the generated images.

This guide will assist you in adjusting and understanding the training parameters for the BEGAN model in this project.


Understanding Key Parameters

  • batch_size: Number of training samples processed in one forward/backward pass (one iteration). A larger batch size can speed up training but requires more memory.

  • channels_img: Number of channels in the input image. For RGB images, this is 3.

  • continue_last_training: Determines if training should continue from the last checkpoint or start anew. Null by default.

  • d_beta_max & d_beta_min: Maximum and minimum beta values for the discriminator's optimizer. They affect learning rate adaptation.

  • epoch_start & epoch_end: Defines the starting and ending epoch for training, especially useful for continuing training from a certain point.

  • features_d & features_g: Number of features in the discriminator (features_d) and generator (features_g). These parameters define the complexity of the networks. Defaults are 128.

  • fps: Frames per second for generated videos.

  • gamma: A control parameter for balancing the losses of the generator and discriminator.

  • g_beta_max & g_beta_min: Maximum and minimum beta values for the generator's optimizer.

  • image_size: The dimensions (width and height) of the output images from the generator. Default size is 64x64 pixels.

  • interpolate_points: Number of points for interpolation, useful when generating transitional images or videos between two points in latent space.

  • k: Initial value controlling the equilibrium between the generator and discriminator losses.

  • lambda_k: Controls the rate of change for k during training.

  • lr_d & lr_g: Learning rates for the discriminator (lr_d) and generator (lr_g). The learning rate defines the step size used when adjusting model weights after each epoch.

  • num_epochs: Total number of times the entire dataset gets shown to the model during training.

  • num_samples: Defines how many samples to generate when creating output images.

  • resume_training: Determines if training should resume from a previous checkpoint. Null by default.

  • sample_size: Size of the sample images to generate for checking model's progress during training.

  • save_model_at: Frequency (in epochs) at which model checkpoints are saved. For example, a value of 50 means the model gets saved every 50 epochs.

  • seed: Random seed for ensuring reproducibility.

  • steps_between: Number of images generated between each interpolated point when creating videos.

  • training_version: Version or identifier for the current training session. This is useful for keeping track of different training runs and their parameters.

  • upscale: Allows for upscaling the generated images or videos. Can be set to a specific resolution or left as null for no upscaling.

  • z_dim: Size of the random noise vector that the generator uses to produce images.


Adjusting Parameters

The src/json/params.json file contains default parameters optimized for this architecture.

To adjust:

  1. Navigate to the src/json/params.json file.

  2. Open it in a text editor or IDE.

  3. Modify the desired parameters. Ensure you input valid data types (e.g., an integer for batch size).

  4. Save the file before starting your training.


Best Practices

  1. Start with Defaults: If you're new to GANs, begin with the default parameters provided and observe the results.

  2. Small Adjustments: When tuning, make small incremental changes. This helps in understanding the impact of each parameter.

  3. Monitor Training: Keep an eye on the training process. If the model isn't learning or the loss is fluctuating wildly, consider adjusting parameters.