How to deploy a trained model in Python 3.5 environment?

(Alex Tat-Sang Choy) #1

I need to deploy a model I trained in our environment which is Python 3.5 and I can’t upgrade the Python without affecting 10 other people’s previous work. So my options now are:

  1. modify to work in Python 3.5 (not sure how much work it is)
  2. save model as a pytorch model (*.pth):
    Tried, but learner.models.model are Sequential, which do not have a save method for
  3. save model (*.h5) and load it in pytorch:
    Seems that I need to reconstruct the model before loading it.
  4. other methods.

Any suggests may help greatly.
Thanks for reading!

(Alex Tat-Sang Choy) #2

Just a follow-up, I tried #1 and it turns out the amount of work is small, just change every f’’ format string into older form seems to work. Hope I didn’t miss any other Python 3.6 only features.

(Alli Babar) #3


You can include the whole in a vShare Class. And inherit it in another sub-class Aptoide.


(Alli Babar) #4


Another way is to make use of Java concept to perform the task. Follow 9Apps .



I am interested in the 3rd option. Keep us posted

(Alex Tat-Sang Choy) #6

Follow up on 2, turn out this is really simple:

model = learn.model, 'my_model')

That’s it, then it can be loaded in pytorch with

model = torch.load('my_model')

Just remember to use


for influence.