Learn.load error when a new instance of jupyter notebook

Hello,

My kernel blocked so I was obliged to restart it - and now I want to save time (to skip the steps where I computed the weights) and I try to load the saved weights but I have this error

Thanks in advance!

Here is it what I’ve run after kernel restart

# Put these at the top of every notebook, to get automatic     reloading and inline plotting
%reload_ext autoreload
%autoreload 2
%matplotlib inline
import torch
# This file contains all the main external libs we'll use
from fastai.imports import *

from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *
# ? Used Resnet34 since resnext didn’t load for some errors
sz=224
arch=resnet34
bs=24
data = get_data(sz,bs)
learn = ConvLearner.pretrained(arch,data, precompute=True) #, ps=0.5
learn.load('224_pre')
1 Like

@alessa change precompute to False and try again because you are not training anything in this instance

1 Like

See jeremy’s reply here on the solution: How to read StackTrace of Error

As I understand it, you have to explicitly create learn object and say learn.precompute = True/False whatever it was (when you saved the object) before loading the object.

2 Likes

Thank you for your answers. :slight_smile:

Now there is a new error: KeyError

Were you able to figure this out ?

I faced a similar error. I think if you saved it with precompute=True. You need to load it to a learn object which has precompute =False. And vice versa. ie. If you saved it with precompute=False, then load it into an object with precompute =True