I am working on an audio classification project where I’m converting audio into spectrograms (1-channel images) and want the model to classify whether the spectrogram belongs to one of two classes. I perform this conversion on the fly, i.e. not saving any images locally, and have my input data now in form of a tensor with the shape: torch.Size([398709, 1, 128])
(398,709 training examples, 1 channel, 128 image size.)
I have my targets in form of a tensor, too, with shape: torch.Size([398709, 1])
(398,709 outputs of 0 or 1) I can also have this data in form of a list with a length of 398709 elements.
My question is: How to pass my data in form of tensors into Datasets
or DataLoaders
?
I have tried creating get_x
and get_y
functions like this (where x is the tensor with spectrograms and y the tensor with targets):
def get_x(x) :
return x
def get_y(x) :
return y
But I’m getting
Creating a dataset using list(zip(x,y))
, then creating a training DataLoader
and a valid DataLoader
but then I’m also getting errors, and nothing seems to work. Any help would be highly appreciated!