I have a text classifier learner that I initialized with
learner = text_classifier_learner(clas_dls, AWD_LSTM, drop_mult=0.5, path=PATH, cbs=SaveModelCallback(), metrics=[accuracy, ispersuasion]).to_fp16()
After training it and then exporting with
learner.export('rev4-1.0.1.model')
It isn’t able to make a prediction with .predict()
, it fails with
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-44-0094604f0cdc> in <module>()
----> 1 learner.predict("asdf")
3 frames
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in predict(self, item, rm_type_tfms, with_input)
254 def predict(self, item, rm_type_tfms=None, with_input=False):
255 dl = self.dls.test_dl([item], rm_type_tfms=rm_type_tfms, num_workers=0)
--> 256 inp,preds,_,dec_preds = self.get_preds(dl=dl, with_input=True, with_decoded=True)
257 i = getattr(self.dls, 'n_inp', -1)
258 inp = (inp,) if i==1 else tuplify(inp)
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in get_preds(self, ds_idx, dl, with_input, with_decoded, with_loss, act, inner, reorder, cbs, **kwargs)
246 pred_i = 1 if with_input else 0
247 if res[pred_i] is not None:
--> 248 res[pred_i] = act(res[pred_i])
249 if with_decoded: res.insert(pred_i+2, getattr(self.loss_func, 'decodes', noop)(res[pred_i]))
250 if reorder and hasattr(dl, 'get_idxs'): res = nested_reorder(res, tensor(idxs).argsort())
/usr/local/lib/python3.6/dist-packages/fastai/losses.py in activation(self, x)
43 def __init__(self, *args, axis=-1, **kwargs): super().__init__(nn.CrossEntropyLoss, *args, axis=axis, **kwargs)
44 def decodes(self, x): return x.argmax(dim=self.axis)
---> 45 def activation(self, x): return F.softmax(x, dim=self.axis)
46
47 # Cell
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in softmax(input, dim, _stacklevel, dtype)
1510 dim = _get_softmax_dim('softmax', input.dim(), _stacklevel)
1511 if dtype is None:
-> 1512 ret = input.softmax(dim)
1513 else:
1514 ret = input.softmax(dim, dtype=dtype)
AttributeError: 'tuple' object has no attribute 'softmax'
This is all done on Google Colab using fastai v2.2.2