Skip to content

Commit

Permalink
Update dcgan.cpp (Taeung#765)
Browse files Browse the repository at this point in the history
Fix AdamOptions initialization error with latest libtorch.

Error without this change: 

```
dcgan.cpp:124:64: error: no member named 'beta1' in 'torch::optim::AdamOptions'
      generator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));
```
  • Loading branch information
kasimte authored May 3, 2020
1 parent e49fa58 commit b9f3b2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/dcgan/dcgan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ int main(int argc, const char* argv[]) {
torch::data::DataLoaderOptions().batch_size(kBatchSize).workers(2));

torch::optim::Adam generator_optimizer(
generator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));
generator->parameters(), torch::optim::AdamOptions(2e-4).betas(std::make_tuple (0.5, 0.5)));
torch::optim::Adam discriminator_optimizer(
discriminator->parameters(), torch::optim::AdamOptions(2e-4).beta1(0.5));
discriminator->parameters(), torch::optim::AdamOptions(2e-4).betas(std::make_tuple (0.5, 0.5)));

if (kRestoreFromCheckpoint) {
torch::load(generator, "generator-checkpoint.pt");
Expand Down

0 comments on commit b9f3b2e

Please sign in to comment.