Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set parameter list to multiple optimizers? #14

Open
kitaev-chen opened this issue Aug 23, 2022 · 2 comments
Open

How to set parameter list to multiple optimizers? #14

kitaev-chen opened this issue Aug 23, 2022 · 2 comments

Comments

@kitaev-chen
Copy link

People usually use multiple module & optimizer on GAN model, for example:

moduleA = Generator()
moduleB = Discriminator()
moduleC = Predictor()

so the corresponding optimizers are:

optG = optim.Adam(Generator.parameters(), ...)
optD = optim.Adam(Discriminator.parameters(), ...)
optP = optim.Adam(Predictor.parameters(), ...)

For single module, the example show:

model = Model()
optimizer = optim.Adam([
                {'params': model.parameters()},
                {'params': awl.parameters(), 'weight_decay': 0}	
            ])

For the multiple modules above, how to set the parameters in optimizers? I can guess two options but they might be wrong:
option1:

optG = optim.Adam(list(Generator.parameters()), ...)
optD = optim.Adam(list(Discriminator.parameters()), ...)
optP = optim.Adam(list(Predictor.parameters())+list(awl.parameters()), ...)

option2:

optG = optim.Adam(list(Generator.parameters())+list(awl.parameters()), ...)
optD = optim.Adam(list(Discriminator.parameters())+list(awl.parameters()), ...)
optP = optim.Adam(list(Predictor.parameters())+list(awl.parameters()), ...)

@Mikoto10032
Which one is correct?

Thanks!

@kitaev-chen kitaev-chen changed the title How to set parameter list to multiple optimizer? How to set parameter list to multiple optimizers? Aug 23, 2022
@long123524
Copy link

Same question. Have you solved it yet? Thank you

@kitaev-chen
Copy link
Author

Same question. Have you solved it yet? Thank you

No, I'm still thinking about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants