diff --git a/experiments/cls_test_wt103_1_f.ipynb b/experiments/cls_test_wt103_1_f.ipynb index 26a6e2e..ee3fd22 100644 --- a/experiments/cls_test_wt103_1_f.ipynb +++ b/experiments/cls_test_wt103_1_f.ipynb @@ -714,9 +714,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:fastaiv1]", + "display_name": "fastai-dev", "language": "python", - "name": "conda-env-fastaiv1-py" + "name": "fastai-dev" }, "language_info": { "codemirror_mode": { @@ -728,7 +728,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.6.8" } }, "nbformat": 4, diff --git a/tests/test_text_data.py b/tests/test_text_data.py index 6b3dabf..1b96079 100644 --- a/tests/test_text_data.py +++ b/tests/test_text_data.py @@ -22,38 +22,35 @@ def test_should_load_backwards_lm(): df = text_df(['neg','pos']) data = TextLMDataBunch.from_df(path, train_df=df, valid_df=df, label_cols=0, text_cols=["text"], bs=2, - lm_type=contrib_data.LanguageModelType.BwdLM, - ld_cls=contrib_data.LanguageModelLoader) + lm_type=contrib_data.LanguageModelType.BwdLM) lml = data.train_dl.dl lml.data = lml.batchify(np.concatenate([lml.dataset.x.items[i] for i in range(len(lml.dataset))])) batch = lml.get_batch(lml.data, 0, 70) - assert batch[0].shape == (70, lml.bs) + assert batch[0].shape == (lml.bs, 70) assert batch[1].shape == (70*lml.bs,) - - as_text = [lml.dataset.vocab.itos[x] for x in batch[0][:,0]] - np.testing.assert_array_equal(as_text[:5], ["world", "hello", '1', 'xxfld', 'project',]) + as_text = [lml.dataset.vocab.itos[x] for x in batch[0][0]] + np.testing.assert_array_equal(as_text[:5], ["world", "hello", 'xxbos', 'project', 'cool']) def test_should_load_bi_lm(): path = untar_data(URLs.IMDB_SAMPLE) df = text_df(['neg', 'pos']) data = TextLMDataBunch.from_df(path, train_df=df, valid_df=df, label_cols=0, text_cols=["text"], bs=2, - lm_type=contrib_data.LanguageModelType.BiLM, - ld_cls=contrib_data.LanguageModelLoader) + lm_type=contrib_data.LanguageModelType.BiLM) lml = data.train_dl.dl lml.data = lml.batchify(np.concatenate([lml.dataset.x.items[i] for i in range(len(lml.dataset))])) batch = lml.get_batch(lml.data, 0, 70) - assert batch[0].shape == (70, lml.bs, 2) + assert batch[0].shape == (lml.bs, 70, 2) assert batch[1].shape == (70*lml.bs, 2) - as_text = [lml.dataset.vocab.itos[x] for x in batch[0][:, 0, 0]] - np.testing.assert_array_equal(as_text[:7], "xxfld 1 fast ai is a cool".split()) + as_text = [lml.dataset.vocab.itos[x] for x in batch[0][0, :, 0]] + np.testing.assert_array_equal(as_text[:7], "xxbos fast ai is a cool project".split()) - as_text = [lml.dataset.vocab.itos[x] for x in batch[0][:,0,1]] - np.testing.assert_array_equal(as_text[:5], ["world", "hello", '1', 'xxfld', 'project',]) + as_text = [lml.dataset.vocab.itos[x] for x in batch[0][0, :, 1]] + np.testing.assert_array_equal(as_text[:5], ["world", "hello", 'xxbos', 'project', 'cool']) ###################### NEW CODE