Hi, all
I want to train both encoder and discriminator.
(Image -> Encoder -> Discriminator)
But I’m not sure which way is correct.
Anyone can help me?
1st way to do this.
optimizer_encoder = optim.Adam(...)
optimizer_discriminator = optim.Adam(...)

# For discriminator 
optimizer_discriminator.zero_grad()
discriminator_loss.backward()
optimizer_discriminator.step()

# For encoder 
optimizer_encoder.zero_grad()
encoder_loss.backward()
optimizer_encoder.step()

2nd way to do this
learnable_params = list(encoder.parameters()) + list(discriminator.parameters())
optimizer_dis_tgt = optim.Adam(learnable_params, ...)

optimizer_all.zero_grad()
total_loss = discriminator_loss+ encoder_loss
total_loss.backward()
optimizer_all.step()