TypeError: get_language_model() got an unexpected keyword argument 'pad_idx'

There seems to be a change from 3 days ago that is affecting this line of code in lesson4-imdb.ipynb:

learner = md.get_model(opt_fn, em_sz, nh, nl,
               dropouti=0.05, dropout=0.05, wdrop=0.1, dropoute=0.02, dropouth=0.05)

Which returns the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-37-b2f8cd3a0b3e> in <module>()
      1 learner = md.get_model(opt_fn, em_sz, nh, nl,
----> 2                dropouti=0.05, dropout=0.05, wdrop=0.1, dropoute=0.02, dropouth=0.05)
      3 learner.reg_fn = partial(seq2seq_reg, alpha=2, beta=1)
      4 learner.clip=0.3

~/fastai/courses/dl1/fastai/nlp.py in get_model(self, opt_fn, emb_sz, n_hid, n_layers, **kwargs)
    268 
    269         """
--> 270         m = get_language_model(self.nt, emb_sz, nhid=n_hid, nlayers=n_layers, pad_idx=self.pad_idx, **kwargs)
    271         model = SingleModel(to_gpu(m))
    272         return RNN_Learner(self, model, opt_fn=opt_fn)

TypeError: get_language_model() got an unexpected keyword argument 'pad_idx'

I see that get_language_model function takes an argument pad_token and not pad_idx. I can simply change the name of it and create a PR if anybody could confirm that seems like a reasonable fix. @jeremy?

Thank you!!

I ran into this and a git pull will fix it.

1 Like