The custom dataset will return image in tensor and its label. My questions are:
What is the data format of label class? If return label as a tensor, which one is correct:
class_id = torch.tensor(class_id) --->dataloader return label size of [batch]
or
class_id = torch.tensor([class_id])--->dataloader return label size of [batch, 1],here 1 is dimension of label
Can getitem method return a range of data points? I know dataset[0] return first element, but is dataset[2:10] feasible in custom dataset and dataloader? If feasible, how?
Can anyone help me if possible please? Thanks a lot! I look forward to any reply!!
If I remember correctly [batch] should be fine and is expected for standard loss functions such as cross entropy loss: CrossEntropyLoss — PyTorch 1.10 documentation (see docs saying labels should have shape (N)).