training discriminator five time for WGAN and generator only one
#Is there a more efficient method to train discriminator for 5 times and the
#generator for only one time?
def configure_optimizers(self):
genOptim=optim.Adam(self.Generator.parameters(),lr=self.hparams.lr_gen)
disOptim=optim.Adam(self.Discriminator.parameters(),lr=self.hparams.lr_dis)
return [disOptim,disOptim,disOptim,disOptim,disOptim,genOptim],[] #5 times training of discriminator
def training_step(self,train_batch,batch_idx,optimizer_idx):
if optimizer_idx<5:#disOptim
#...
return {'loss':loss_dis,'loss_dis':loss_dis}
if optimizer_idx==5:#genOptim
#...
return {'loss':loss_gen,'loss_gen':loss_gen}