MinfengZhu / DM-GAN

MIT License
187 stars 64 forks source link

error when using captions from text file for validation #19

Closed tejas-gokhale closed 3 years ago

tejas-gokhale commented 4 years ago

Hi,

I'm trying to load captions from txt files during validation (i.e. the if block on line 223 in datasets.py). However it gives me the following error: RuntimeError: Error(s) in loading state_dict for RNN_ENCODER: size mismatch for encoder.weight: copying a param of torch.Size([26835, 300]) from checkpoint, where the shape is torch.Size([27297, 300]) in current model.

This has also been reported in the AttnGAN issues: https://github.com/taoxugit/AttnGAN/issues/45 Would be great if you could tell me why this error pops up using txt files.

The validation works if I use the default method.

MinfengZhu commented 3 years ago

If you want to generate images from customized descriptions, you should modify B_VALIDATION to False.

https://github.com/MinfengZhu/DM-GAN/blob/d515995b6fade48be9762c7f069c9d889d4d5559/code/cfg/eval_bird.yml#L8

tejas-gokhale commented 3 years ago

Thanks @WhereISmyroad and @MinfengZhu . Another thing worth mentioning here is that the vocabulary (build_dictionary) of the pre-trained RNN_ENCODER and the new input captions must be the same -- that's the reason for the error. Two solutions are

  1. to load the dictionary for the pre-trained model
  2. train rnn-encoder with the new dictionary.

Closing the issue. Thanks!