Created
July 9, 2019 20:27
-
-
Save svenski/38474ff6ba2fa3ddd026acb846a924ed to your computer and use it in GitHub Desktop.
MultilabelFbeta bug reproducible code
This file contains 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
from fastai import * | |
from fastai.text import * | |
bs=48 | |
path = untar_data(URLs.IMDB) | |
path.ls() | |
data_lm = (TextList.from_folder(path) | |
.filter_by_folder(include=['train', 'test', 'unsup']) | |
.split_by_rand_pct(0.1, seed=42) | |
.label_for_lm() | |
.databunch(bs=bs, num_workers=1)) | |
learn_lm = language_model_learner(data_lm, AWD_LSTM, drop_mult=0.3) | |
data_clas = (TextList.from_folder(path, vocab=data_lm.vocab) | |
.split_by_folder(valid='test') | |
.label_from_folder(classes=['neg', 'pos']) | |
.databunch(bs=bs, num_workers=1)) | |
learn_c = text_classifier_learner(data_clas, AWD_LSTM, drop_mult=0.3) | |
micro_f1 = MultiLabelFbeta(learn_c, beta=1, thresh=0.5, average="micro") | |
learn_c.metrics = [micro_f1] | |
learn_c.save('bla') | |
learn_c.load('bla') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment