Separate optimizer for discriminator and the rest of the model in adversarial setting
I have a model with the following components.


embedding layer
encoder
generator
discriminator
feed-forward neural network


I want to define two optimizers. One for the discriminator only and one for the rest. I am doing the following.

optimizers = []
model_params = chain(model.embedding.parameters(), model.encoder.parameters(), 
                            model.generator.parameters(), model.ffnn.parameters())
optimizers.append(optim.Adam(model_params, args.lr))
optimizers.append(optim.Adam(model.discriminator.parameters(), args.lr))


Is there any better way to do the same? For example, can I take the difference between model.parameters() and model.discriminator.parameters()? If yes, how can I do that?

no, because model.parameters() returns a generator. If you want to modify a generator like you want it you have to convert it to a list anyway.
