Lesson 4 imdb - exception when creating the learner

I got an exception when executing the step that instantiates the learner. Namely, the following line:

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)

And it produced:


235 rnn_enc = RNN_Encoder(n_tok, emb_sz, nhid=nhid, nlayers=nlayers, pad_token=pad_token,
–> 236 dropouth=dropouth, dropouti=dropouti, dropoute=dropoute, wdrop=wdrop, qrnn=qrnn, bias=bias)
237 enc = rnn_enc.encoder if tie_weights else None
238 return SequentialRNN(rnn_enc, LinearDecoder(n_tok, emb_sz, dropout, tie_encoder=enc))

TypeError: init() got an unexpected keyword argument ‘bias’

It looks like the bias parameter was added just three days ago. Is it ok if I just remove it temporarily? Are there any hidden consequences? Anyway, please help

The current version is broken, waiting for a pull request. It’s in the waiting list as I understand.
I made modification to the source directly.
If you’d like to do that, just add parameter: bias=false to RNN_Encoder initializer.

Not sure if you figured this out, but I had the same problem. The patch suggested by Urmas Pitsi works (add bias = False to the sequentialRNN class (def get_language_model) in the lm_rnn.py file. I’ve attached a link to a modified version of the file to save a little time. Move the current lm_rnn.py file somewhere (e.g. rename to lm_rnn.py.old) and put this file in the same directory (fastai).

lm_rnn.py

-Frank

in lm_rnn.py I have bias = False in the sequentialRNN class. But I still get the error :

TypeError Traceback (most recent call last)
in ()
----> 1 learner = md.get_model(opt_fn, em_sz, nh, nl,dropout=0.05, dropouth=0.1, dropouti=0.05, dropoute=0.02, wdrop=0.2)
2 # dropout=0.4, dropouth=0.3, dropouti=0.65, dropoute=0.1, wdrop=0.5
3 # dropouti=0.05, dropout=0.05, wdrop=0.1, dropoute=0.02, dropouth=0.05)
4 learner.reg_fn = partial(seq2seq_reg, alpha=2, beta=1)
5 learner.clip=0.3

/notebooks/fastai/nlp.py in get_model(self, opt_fn, emb_sz, n_hid, n_layers, **kwargs)
274
275 “”"
–> 276 m = get_language_model(self.nt, emb_sz, n_hid, n_layers, self.pad_idx, **kwargs)
277 model = SingleModel(to_gpu(m))
278 return RNN_Learner(self, model, opt_fn=opt_fn)

/notebooks/fastai/lm_rnn.py in get_language_model(n_tok, emb_sz, nhid, nlayers, pad_token, dropout, dropouth, dropouti, dropoute, wdrop, tie_weights, qrnn, bias)
234
235 rnn_enc = RNN_Encoder(n_tok, emb_sz, nhid=nhid, nlayers=nlayers, pad_token=pad_token,
–> 236 dropouth=dropouth, dropouti=dropouti, dropoute=dropoute, wdrop=wdrop, qrnn=qrnn, bias=bias)
237 enc = rnn_enc.encoder if tie_weights else None
238 return SequentialRNN(rnn_enc, LinearDecoder(n_tok, emb_sz, dropout, tie_encoder=enc))

TypeError: init() got an unexpected keyword argument ‘bias’

Do you have any Idea ?

@MazyDusty: I made the change in the init call for RNN_Encoder and it worked.

(We’re not fixing the code, just applying some duct tape get it running.)