Hi there,
I’ve been trying on the wgan in lesson 7 ie:
I wanted to save the model at a certain point then load i.e. I saved a checkpoint after training:
learn.save(dest/‘gan-model’)
then loaded into a new learner i defined with the same architecture:
learn2 = GANLearner.wgan(data, generator, critic, switch_eval=False, opt_func = partial(optim.Adam, betas = (0.,0.99)), wd=0.)
learn2.load(‘gan-model’)
This all works fine so far.
Then when i try and switch predict/generate images:
learn2.gan_trainer.switch(gen_mode=True)
I get the following errors:
AttributeError Traceback (most recent call last)
in () ----> 1 learn2.gan_trainer.switch(gen_mode=True)
1 frames
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in getattr(self, k) 441 setattr(self.learn, self.cb_name, self) 442 → 443 def getattr(self,k): return getattr(self.learn, k) 444 def setstate(self,data:Any): self.dict.update(data) 445
AttributeError: ‘GANLearner’ object has no attribute ‘opt_gen’
I then saw this posting in the forum:
And tried the method it suggested i.e.
learn2.load(‘gan-model’, purge=False)
This made no difference and I still got the same error:
AttributeError: ‘GANLearner’ object has no attribute ‘opt_gen’
Does anyone know how I should be loading and saving the Gan models properly so I can predict?
Thanks!