How do I load a model in Python 3 that was trained and saved using Python 2?

(Chahrazad Essalim) #1

while loading a model trained using python 2 in python 3, i get the error about encoding :

is there any workaround to this ?


it looks like you are saving a string as part of your model. See for example.

Either dont save strings on your model, or instead of saving and loading the whole model, you can:, model.state_dict())

model = Model() # construct a new model

See for an example.

(Chahrazad Essalim) #3

this worked thank you.