Getting error on reproducing IMDB dataset

Hello,

I was trying to go with IMDB lesson.

This is the error in the end when I try to load encoder into learner

learn = text_classifier_learner(data_clas, AWD_LSTM, drop_mult=0.5)
learn.load_encoder('fine_tuned_enc')

ā€“

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-82-58fb872cb4e2> in <module>()
      1 learn = text_classifier_learner(data_clas, AWD_LSTM, drop_mult=0.5)
----> 2 learn.load_encoder('fine_tuned_enc')

1 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
    837         if len(error_msgs) > 0:
    838             raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
--> 839                                self.__class__.__name__, "\n\t".join(error_msgs)))
    840         return _IncompatibleKeys(missing_keys, unexpected_keys)
    841 

RuntimeError: Error(s) in loading state_dict for AWD_LSTM:
	size mismatch for encoder.weight: copying a param with shape torch.Size([5488, 400]) from checkpoint, the shape in current model is torch.Size([5112, 400]).
	size mismatch for encoder_dp.emb.weight: copying a param with shape torch.Size([5488, 400]) from checkpoint, the shape in current model is torch.Size([5112, 400]).

What did go wrong?

Maybe this will give you a better idea: https://forums.fast.ai/t/how-to-fix-error-s-in-loading-state-dict-for-awd-lstm-when-using-fast-ai/45024

1 Like