I tried to load pretrained model but have the following error:
RuntimeError: Error(s) in loading state_dict for Discriminator:
size mismatch for final.weight: copying a param with shape torch.Size([1, 128, 1, 1]) from checkpoint, the shape in current model is torch.Size([8, 128, 1, 1]).
size mismatch for final.bias: copying a param with shape torch.Size([1]) from checkpoint, the shape in current model is torch.Size([8]).
Hi @Qi_Yu,
I just tried to confirm and it is working fine for me. The size your error says it is loading from the checkpoint also looks right (matches what I’m seeing). BUT the size for your current model, torch.Size([8, 128, 1, 1]), does NOT match.
Please check your implementation for your line of code in Discriminator that sets self.final. You can run the unit test in the cell immediately following the Discriminator cell to test your discriminator implementation.
If you don’t mind, could you DM me the line you entered that caused the error but passed the unit test? I can pass it along to the development team to see if they want to try to enhance the unit tests to cover this case. Of course, it’s not always practical to cover every case with unit tests, but it’d be worth taking a look.
Ran across this same issue. The issue can be caught by the unit test if we were to initialize the Discriminator w/ the hidden_channels at default value.