The DataLoader calls into Dataset.__getitem__ to get the current sample and creates a batch out of these samples. It can also use different samplers, a custom collate_fn, multiple workers etc.
The image tensor shape if defined in your Dataset, i.e. how you are loading and preprocessing the images. If you want to resize the tensors to a specific shape, you could use transformation such as torchvision.transforms.Resize inside Dataset.__getitem__.
Thank you for your explanation. What I have done is transformed body signals ( 4hz) into a graph using mathplotlib. I then save them as a png, so I have like 200 png files. I will try later today to load them using your tips. Let’s see how I go.
Note, and it goes without saying I am a very beginner in the world of deep learning.
It depends a bit what the dimensions represent.
If dim0 is the batch dimension and you are only dealing with a single feature, you could try to use transposed convolutions to upsample the single sample.
On the other hand, if both dimensions represent some kind of features, you could try to reshape the input to e.g. an image tensor of [batch_size, 1, 8, 5] and create a custom CNN which could deal with these tiny images.
Note that CNNs try to use the spatial features of your data. If your data doesn’t contain any correlation between neighboring values, I would rather stick to linear layers.
Hi Patrick, I am dealing with body signals as responses from certain stimuli, and I need to use this stimulus to classify a class. So far I manage to get the 1d working Thank so much)
But for example, you can use libraries such as librosa to transform the sound into signals representations. Its is just a time series of 40 or 80 points, but there is a time attached, so they correlate.
When Inspect the images which are a time series, there are not really a lot of similarities in the curves. So what I am doing is trying to normalize and centre all the signals first. Once this is done I am planning to save these images as png in a folder. Load as a picture and then classify using a conv2d.
Are you planning on saving images of the waveform and classify it with a CNN?
This might work, if you see that these waveforms differ enough between classes.
However, I would also recommend to check, if creating spectra wouldn’t work better.
Saved the images as png to try fitting a 2d CNN, really struggling to load a png properly. I think im not that far. I’ve followed the PyTorch tutorial then had a PIL error, got some help and fix that, now another error:
PicklingError: Can’t pickle <class ‘main.MyDataset’>: it’s not the same object as main.MyDataset