yxlijun / DSFD.pytorch

DSFD implement with pytorch
167 stars 58 forks source link

Error while loading weights #10

Closed testingshanu closed 5 years ago

testingshanu commented 5 years ago

Hey, I was trying to resume the training from the saved weights. However a problem occurs while loading the weights stating :

KeyError: 'weight'

from DSFD_vgg.py

When I print out the keys in the saved weights, I could not find both weight and epochs as mentioned in the code.

Any solution to solve it?

Thank you,

testingshanu commented 5 years ago

solved it by changing the way how the model is saved.

abhi1nandy2 commented 5 years ago

How did you change the way the model is saved @testingshanu ?

huangxGo commented 4 years ago

How did you change the way the model is saved @testingshanu ?

https://pytorch.org/docs/stable/notes/serialization.html#recommend-saving-models In the official Pytorch docs, there are two ways to save the model:

  1. torch.save(the_model.state_dict(), PATH) which saves and loads only the model parameters
  2. torch.save(the_model, PATH) which saves and loads the entire model

I think you should use the second way to save the model