auspicious3000 / autovc

AutoVC: Zero-Shot Voice Style Transfer with Only Autoencoder Loss
https://arxiv.org/abs/1905.05879
MIT License
976 stars 207 forks source link

An error is reported when the trained model is tested #115

Closed SeptemberN closed 1 year ago

SeptemberN commented 2 years ago

I saved the model using torch.save() in slover_encoder.py, but I get an error when loading it in conversion.ipynb. None of the model parameters have been changed, why? torch.save(self.G.state_dict(), 'g.ckpt') The error is as follows:

RuntimeError: Error(s) in loading state_dict for Generator:
    size mismatch for encoder.lstm.weight_ih_l0: copying a param with shape torch.Size([64, 512]) from checkpoint, the shape in current model is torch.Size([128, 512]).
    size mismatch for encoder.lstm.weight_hh_l0: copying a param with shape torch.Size([64, 16]) from checkpoint, the shape in current model is torch.Size([128, 32]).
    size mismatch for encoder.lstm.bias_ih_l0: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
    size mismatch for encoder.lstm.bias_hh_l0: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
    size mismatch for encoder.lstm.weight_ih_l0_reverse: copying a param with shape torch.Size([64, 512]) from checkpoint, the shape in current model is torch.Size([128, 512]).
    size mismatch for encoder.lstm.weight_hh_l0_reverse: copying a param with shape torch.Size([64, 16]) from checkpoint, the shape in current model is torch.Size([128, 32]).
        ...
SeptemberN commented 2 years ago

Sorry, I made a mistake in the parameters in the program myself. It has now been resolved.

dnjdsxor21 commented 1 year ago

@SeptemberN Hello, I got same error with you, using code: torch.save({'model': self.G.state_dict(), 'optimizer': self.g_optimizer.state_dict()}, 'autovc.ckpt')

How did you remove 'the size mismatch error'?

SeptemberN commented 1 year ago

Hi! You can try to check and modify the added parameters of "parser" in main.py. The shape of the trained model should be consistent with the input data. Tips: You can run 100 saves and test if the model is available