What should be the type
of the data I return through the __getitem__
method of the dataloader class if I use the default collate_fn
? I am confused because the dimensions I get are different depending on the type that I return.
If I return a list, then the length of my data is 34 instead of batch_size
.
def __getitem__(self, index):
df = self.df.iloc[index]
keypoint = df["keypoint"]
# print(type(keypoint)) = <class 'list'>
# print(np.shape(keypoint)) = (34,)
return keypoint
If I return a tensor, then the length of my data is batch_size
. What is happening in the collate_fn?
def __getitem__(self, index):
df = self.df.iloc[index]
keypoint = torch.Tensor(np.array(df["keypoint"]))
return keypoint