PyTorch-GAN icon indicating copy to clipboard operation
PyTorch-GAN copied to clipboard

load and save checkpoint logic error

Open John155 opened this issue 4 years ago • 1 comments

Save checkpoint code, for example in the MUNIT GAN:

parser.add_argument("--epoch", type=int, default=0, help="epoch to start training from")
parser.add_argument("--checkpoint_interval", type=int, default=1, help="interval between saving model checkpoints")
for epoch in range(opt.epoch, opt.n_epochs):
    for i, batch in enumerate(dataloader):

  if opt.checkpoint_interval != -1 and epoch % opt.checkpoint_interval == 0:
  torch.save(Enc1.state_dict(), "saved_models/%s/Enc1_%d.pth" % (opt.dataset_name, epoch))

The Problem
You will save the first checkpoint with epoch 0, but in the restore function, u cannot load form an epoch 0.
Load checkpoints, for example in the MUNIT GAN:
if opt.epoch != 0:
   # Load pretrained models

else: 
   # Initialize weights

John155 avatar Aug 30 '21 09:08 John155

i think you can change the if statement to enable loading from epoch 0.

nixczhou avatar Sep 08 '21 15:09 nixczhou