Thank you for your response @ptrblck. It is now running as expected; this happened without a single code change, so I am very confused.
I pickle.dump()ed it to a binary file. I’m storing it because I need to use the same datasets for a series of experiments.
I didn’t get the error when I run the above in IPython, or if I recreate the Dataset and pass it to the DataLoader. It was only happening when I ran it in a script from the command line.