I created a custom dataset, and I'm wondering why the answer object has no data type?
the dataloader singel output:
{'answer': tensor([1]),
'image': tensor([[[0.0000, 0.6180, 0.0000, ..., 0.0000, 0.0000, 0.0000]]],
device='cuda:0'),
'question': tensor([[ 3, 6, 8, 1274, 593, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0]], dtype=torch.int32)}
the custom dataset:
class VQAdataset(Dataset):
def __init__(self,img_data, que_data, ans_data, top_1000_answers):
self.que_data=que_data
self.ans_data=ans_data
self.img_data=img_data
self.top_answers=top_1000_answers
def __getitem__(self,index):
if torch.is_tensor(index):
index = index.tolist()
question_item=self.que_data[index]
answer_item=self.ans_data[index]
answer_item_index=torch.tensor(self.top_answers.index(answer_item),dtype=torch.int64)
image_item=self.img_data[index]
example={'image': image_item, 'question': question_item, 'answer': answer_item_index}
return example
def __len__(self):
return len(self.que_data)
Does the data type attribute important to the loss calculation?
question from:
https://stackoverflow.com/questions/65841893/does-tensor-label-for-loss-calculation-in-crossentropy-must-has-dtype-why-my-ob