Training parameters

In each of the flipcoin events in the training code, consider making a modifiable parameter in the run script. As a reminder, the pseudocode is as follows:

### Pseudocode
On Epoch:
Batch Size = ##
flipcoin()
x_train = Half of Batch From Real Images
y_train = 1s (Real) x Batch Size
else:
x_train = Half of Batch from Generated Images
y_train = 0s (Fake) x Batch Size

train_discriminator(x_train,y_train)

x_generated_images = generator(batch_size)
flipcoin()
y_labels = 1s for Real
else:
y_labels = 0s for Fake (Noisy Labels)
train_gan(x_generated_images,y_labels)

Each flipcoin step has a changeable parameter, and exposing this parameter allows you to modify how often you provide real or generated images in discriminator training. In the second flipcoin event, we can also induce additional label noise on GAN training. Both of these parameters should be exposed and tuned for your application; the following steps can be used as an example:

  1. The flipCoin method in the training script is as follows:
# Train Discriminator
# Make the training batch for this model be half real, half noise
# Grab Real Images for this training batch
if self.flipCoin():
  1. The following code is the flipCoin definition:
def flipCoin(self,chance=0.5):
return np.random.binomial(1, chance)

Notice that we can change the chance that this evaluates to true. This is an important parameter to consider in discriminator training, as it will lead to more, or fewer, generated images in the process.

  1. To change the parameter and adjust it, use the following code:
# Train Discriminator
# Make the training batch for this model be half real, half noise
# Grab Real Images for this training batch
if self.flipCoin(chance=0.8):
  1. Now, see what results you get!
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.189