How to import TextLMDataBunch?

I am following this tutorial to build a NLP sentiment analysis model.

from fastai.text import *

This is the only import specified that includes fastai.

Unfortunately the TextLMDataBunch is undefined.

What import should I used to have this class avaialable?

I have already tried:

from fastai.text.data import TextLMDataBunch

But apparently fastai.text.data is not even a package.

Consequently I checked the source on github.

https://github.com/fastai/fastai/blob/master/fastai/text/data.py does not include TextLMDataBunch, but https://github.com/fastai/fastai1/blob/master/fastai/text/data.py#L240 does.

So how do I import from fastai1 ? Is this an older are newer version.

Hi,

That tutorial seems like it’s for the V1 of FastAI.

Regarding the Source code
https://github.com/fastai/fastai == V2 of FastAI
https://github.com/fastai/fastai1 == V1 of FastAI

I would look at this tutorial: https://docs.fast.ai/tutorial.text.html to use with the V2 of the FastAI library.

1 Like