Last active
May 29, 2018 21:11
-
-
Save hamelsmu/a1749e3b812703aad04e4b90eaee0033 to your computer and use it in GitHub Desktop.
language model used in code search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create data loaders | |
trn_dl = LanguageModelLoader(trn_indexed, bs, bptt) | |
val_dl = LanguageModelLoader(val_indexed, bs, bptt) | |
# create lang model data | |
md = LanguageModelData(mpath, 1, vocab_size, trn_dl, val_dl, bs=bs, bptt=bptt) | |
# build learner. some hyper-params borrowed from fast.ai examples | |
opt_fn = partial(optim.Adam, betas=(0.8, 0.99)) | |
drops = np.array([0.25, 0.1, 0.2, 0.02, 0.15]) * 0.7 | |
learner = md.get_model(opt_fn, em_sz, nh, nl, | |
dropouti=drops[0], | |
dropout=drops[1], | |
wdrop=drops[2], | |
dropoute=drops[3], | |
dropouth=drops[4]) | |
# borrowed these parameters from fastai | |
learner.fit(lr, | |
n_cycle=n_cycle, | |
wds=wd, | |
cycle_len=cycle_len, | |
use_clr=(32, 10), | |
cycle_mult=cycle_mult, | |
best_save_name='langmodel_best') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment