Hi,
I’m training ULMFiT text classification models for a few topics. They seem to be performing quite well on the validation data, so I’d like to wrap them in a small webapp that’d get a new text document as input and will output the models’ prediction. However, I’m can’t call the models’ forward function on a new tensor variable.
The code I’m using (this is reusing the validation data, just to mock a new document):
m = get_rnn_classifer(bptt, 20*70, c, vs, emb_sz=em_sz, n_hid=nh, n_layers=nl, pad_token=1,
layers=[em_sz*3, 50, c], drops=[dps[4], 0.1],
dropouti=dps[0], wdrop=dps[1], dropoute=dps[2], dropouth=dps[3])
opt_fn = partial(optim.Adam, betas=(0.7, 0.99))
learn = RNN_Learner(md, TextModel(to_gpu(m)), opt_fn=opt_fn)
learn.reg_fn = partial(seq2seq_reg, alpha=2, beta=1)
learn.clip=25.
learn.metrics = [accuracy]
lr=3e-3
lrm = 2.6
lrs = np.array([lr/(lrm**4), lr/(lrm**3), lr/(lrm**2), lr/lrm, lr])
wd = 1e-7
wd = 0
learn.load_encoder('lm1_enc')
learn.load('clas_final')
idx = np.array(val_clas[i])[None]
idx = np.transpose(idx)
tensorIdx = VV(idx)
m.forward(tensorIdx)
but I get the following error message:
AttributeError: 'MultiBatchRNN' object has no attribute 'hidden'