Skip to content
Snippets Groups Projects
Commit a8c468d6 authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[trainers] fixed the moving of the model to CPU when generating images

parent 4b219490
No related branches found
No related tags found
1 merge request!4Resolve "Add GANs"
Pipeline #
...@@ -194,9 +194,11 @@ class ConditionalGANTrainer(object): ...@@ -194,9 +194,11 @@ class ConditionalGANTrainer(object):
# tried to move tensors, variables on the GPU -> does not work # tried to move tensors, variables on the GPU -> does not work
# let the tensors on the CPU -> does not work # let the tensors on the CPU -> does not work
# => model has to be brought back to the CPU :/ # => model has to be brought back to the CPU :/
self.netG = self.netG.cpu() if self.use_gpu:
self.netG = self.netG.cpu()
fake_examples = self.netG(self.fixed_noise, self.fixed_one_hot) fake_examples = self.netG(self.fixed_noise, self.fixed_one_hot)
self.netG = self.netG.cuda() if self.use_gpu:
self.netG = self.netG.cuda()
vutils.save_image(fake_examples.data, '%s/fake_samples_epoch_%03d.png' % (output_dir, epoch), normalize=True) vutils.save_image(fake_examples.data, '%s/fake_samples_epoch_%03d.png' % (output_dir, epoch), normalize=True)
# do checkpointing # do checkpointing
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment