Follow this tutorial https://pytorch.org/tutorials/beginner/data_loading_tutorial.html 169 to create your dataset class, basically just switch the image dataset they use with your csv or text dataset file.