Hello! I’m an amateur regarding pytorch. I have a csv file with a column of text and a column of integer labels. How can I load this csv into the dataloader so that I can train a model for classification?
Hi! The most direct way would probably be to create a custom Dataset for your files. It’s quite straightforward, you just inherit the generic class and define the __len__ (in your case just return len(train)) and __getitem__ methods, as described in the tutorial. Good luck!
In the tutorial, the getitem method converts image path to a tensor using read_image. The text in my csv file is not an image path. How would I convert it to a tensor?
Regarding __getitem__, you can customize it to return whatever it is you want to use in your training loop. For example, in your case you may try something like this: