Problem with load_learner()

Hi there

I created a model, exported it and now i’m trying to load it in again.
learn = load_learner(“model.pkl”)

However this throws an error:


Does anyone know what the problem could be here?
Thanks in advance!

Possibly this link may help: Cannot Load Learner in different script


Is get_y_array a function you defined? If so, learn.export can pickle this function (see the docs). You either need to re-define the function, so that it can be loaded from __main__ or you could use dill instead of pickle.


That was indeed the case, I forgot about that method and didn’t remember writing it, it seemed like an internal method to me. I redefined it and I was able to import the model.
Thanks for the help!