I just updated to the latest fastai2 and fastcore files on git. I’m loading a learner I trained last week, and I’m getting:
Traceback (most recent call last):
File "./newfile.py", line 392, in <module>
learn = load_learner('fastai2_05_23.pkl', cpu=False)
File "/home/paperspace/git_packages/fastai2/fastai2/learner.py", line 526, in load_learner
res = torch.load(fname, map_location='cpu' if cpu else None)
File "/home/paperspace/environments/fastai2/lib/python3.6/site-packages/torch/serialization.py", line 593, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/paperspace/environments/fastai2/lib/python3.6/site-packages/torch/serialization.py", line 773, in _legacy_load
result = unpickler.load()
AttributeError: Can't get attribute 'ModelReseter' on <module 'fastai2.callback.rnn' from '/home/paperspace/git_packages/fastai2/fastai2/callback/rnn.py'>
I’m still investigating, but has anyone else seen this?
Note, the original learner doesn’t have that callback:
callbacks = [SaveModelCallback(monitor = 'accuracy',
every_epoch = False),
EarlyStoppingCallback(monitor = 'accuracy', patience=25),
ReduceLROnPlateau(factor=10, patience=1000, min_lr = 0.000001)]
learn = text_classifier_learner(dbunch_class, AWD_LSTM, drop_mult=0.5, metrics=[accuracy, Perplexity()], cbs=callbacks, wd=0.1).to_fp16()
learn = learn.load_encoder('finetuned_67.pkl')
Update:
When I load the saved learner, instead of the exported learner, I get a different error:
>>> learn.load('fastai2_learner_05_23_2')
<fastai2.text.learner.TextLearner object at 0x7f249d3e4d30>
>>>
>>>
>>> learn.predict("Superman")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/paperspace/git_packages/fastai2/fastai2/learner.py", line 251, in predict
dec = self.dls.decode_batch(inp + tuplify(dec_preds))[0]
File "/home/paperspace/git_packages/fastai2/fastai2/data/core.py", line 78, in decode_batch
def decode_batch(self, b, max_n=9, full=True): return self._decode_batch(self.decode(b), max_n, full)
File "/home/paperspace/git_packages/fastai2/fastai2/data/core.py", line 83, in _decode_batch
return L(batch_to_samples(b, max_n=max_n)).map(f)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 377, in map
return self._new(map(g, self))
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 327, in _new
def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 47, in __call__
res = super().__call__(*((x,) + args), **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 318, in __init__
items = list(items) if use_list else _listify(items)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 254, in _listify
if is_iter(o): return list(o)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 220, in __call__
return self.fn(*fargs, **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/utils.py", line 349, in _inner
for f in L(funcs): x = f(x, *args, **kwargs)
File "/home/paperspace/git_packages/fastai2/fastai2/data/core.py", line 297, in decode
def decode(self, o, full=True): return tuple(tl.decode(o_, full=full) for o_,tl in zip(o,tuplify(self.tls, match=o)))
File "/home/paperspace/git_packages/fastai2/fastai2/data/core.py", line 297, in <genexpr>
def decode(self, o, full=True): return tuple(tl.decode(o_, full=full) for o_,tl in zip(o,tuplify(self.tls, match=o)))
File "/home/paperspace/git_packages/fastai2/fastai2/data/core.py", line 233, in decode
def decode(self, o, **kwargs): return self.tfms.decode(o, **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/transform.py", line 195, in decode
if full: return compose_tfms(o, tfms=self.fs, is_enc=False, reverse=True, split_idx=self.split_idx)
File "/home/paperspace/git_packages/fastcore/fastcore/transform.py", line 140, in compose_tfms
x = f(x, **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/transform.py", line 73, in decode
def decode (self, x, **kwargs): return self._call('decodes', x, **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/transform.py", line 82, in _call
return self._do_call(getattr(self, fn), x, **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/transform.py", line 86, in _do_call
return x if f is None else retain_type(f(x, **kwargs), x, f.returns_none(x))
File "/home/paperspace/git_packages/fastcore/fastcore/dispatch.py", line 98, in __call__
return f(*args, **kwargs)
File "/home/paperspace/git_packages/fastai2/fastai2/text/data.py", line 46, in decodes
def decodes(self, o): return L(self.vocab[o_] for o_ in o if self.vocab[o_] != self.pad_tok)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 47, in __call__
res = super().__call__(*((x,) + args), **kwargs)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 318, in __init__
items = list(items) if use_list else _listify(items)
File "/home/paperspace/git_packages/fastcore/fastcore/foundation.py", line 254, in _listify
if is_iter(o): return list(o)
File "/home/paperspace/git_packages/fastai2/fastai2/text/data.py", line 46, in <genexpr>
def decodes(self, o): return L(self.vocab[o_] for o_ in o if self.vocab[o_] != self.pad_tok)
AttributeError: 'Numericalize' object has no attribute 'pad_tok'
>>>
Update 2: Ended up reverting to an older fastai2 build, no longer seeing this. Let me know if there’s anything you’d like me to test!