UndefVarError: DataLoader not defined


I have the latest flux version and I’ve tried everything I could find online but I still get this error when trying to use the DataLoader. Anyone encounter it before and found a fix (if it changes anything I’m running my code out of google colab).


Are you just trying to use it unqualified without explicitly importing it first? Note that this will not work:

using Flux

dl = DataLoader(...) # errors, because Flux does *not* export it

You’ll either have to include (using|import) Flux: DataLoader or prepend the module name as in dl = Flux.DataLoader(..).

I’ve tried using Flux.Data: DataLoader
using Flux: DataLoader
both after import Flux and it still doesn’t work. It’s the only function from flux I’m having this problem with. Thanks!

First things first, make sure your Flux version is up to date (at least v0.13). If not, then check your environment to see if any other dependencies are holding it back (you can search on Discourse for guides on how to do that). If everything looks there (and post your package version info here if it does so we can make sure), then post the exact code, error + stacktrace you’re encountering when trying to use DataLoader. Per Please read: make it easier to help you, “doesn’t work” is not enough to work with :slight_smile: