Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading .npy files as dataset for pytorch

I have preprocessed data in .npy files, let's call it X.npy for raw data and Y.npy for labels. They're organized to match every element from both files (first element from X has first label from Y etc.). How can I load it as dataset using torch.utils.data.DataLoader? I'm very new to pytorch, and any help will be useful.

like image 452
jBloodless Avatar asked Sep 18 '19 09:09

jBloodless


1 Answers

You could also use DatasetFolder, which basically is the underlying class of ImageFolder. Using this class you can provide your own file extensions and loader to load the samples.

def npy_loader(path):
    return torch.from_numpy(np.load(path))
like image 167
Ritik Thakur Avatar answered Oct 19 '22 23:10

Ritik Thakur