Reading this bear in mind that I’m a beginner with pytorch. I think saving the model went wine, I did it using :
torch.save({
'epoch': self.epochs,
'model_state_dict': self.model.state_dict(),
'optimizer_state_dict': self.optimizer.state_dict()
}, 'sav
inside the for loop on epochs.
Then, to load the model, I do this after initializing the model and the optimizer.
if os.path.exists('saved') :
print('Loading saved model')
checkpoint = torch.load('saved')
model.load_state_dict(checkpoint['model_state_dict'])
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
epoch = checkpoint['epoch']
Here’s the error :
Missing key(s) in state_dict: "frame_level_rnns.0.h0", "frame_level_rnns.0.input_expand.bias", "frame_level_rnns.0.input_expand.weight_g", "frame_level_rnns.0.input_expand.weight_v", "frame_level_rnns.0.rnn.weight_ih_l0", "frame_level_rnns.0.rnn.weight_hh_l0", "frame_level_rnns.0.rnn.bias_ih_l0", "frame_level_rnns.0.rnn.bias_hh_l0", "frame_level_rnns.0.rnn.weight_ih_l1", "frame_level_rnns.0.rnn.weight_hh_l1", "frame_level_rnns.0.rnn.bias_ih_l1", "frame_level_rnns.0.rnn.bias_hh_l1", "frame_level_rnns.0.upsampling.bias", "frame_level_rnns.0.upsampling.conv_t.weight_g", "frame_level_rnns.0.upsampling.conv_t.weight_v"
and then shortly after
Unexpected key(s) in state_dict: "model.frame_level_rnns.0.h0", "model.frame_level_rnns.0.input_expand.bias", "model.frame_level_rnns.0.input_expand.weight_g", "model.frame_level_rnns.0.input_expand.weight_v", "model.frame_level_rnns.0.rnn.weight_ih_l0", "model.frame_level_rnns.0.rnn.weight_hh_l0", "model.frame_level_rnns.0.rnn.bias_ih_l0", "model.frame_level_rnns.0.rnn.bias_hh_l0", "model.frame_level_rnns.0.rnn.weight_ih_l1", "model.frame_level_rnns.0.rnn.weight_hh_l1", "model.frame_level_rnns.0.rnn.bias_ih_l1", "model.frame_level_rnns.0.rnn.bias_hh_l1", "model.frame_level_rnns.0.upsampling.bias"
So instead of loading ‘a’ it loads ‘model.a’ I guess, but I don’t get what I am doing wrong. Can you help me out please ?