I am returning three tensors from the getitem function and it only returns the first batch and then start throwing error
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 512])
def __getitem__(self,idx):
semihardtriplet = possible_triplets[idx]#Choice the at about 75 % position
anchor_t = self.path_to_tensor(semihardtriplet.anchor,self.device,False)
positive_t = self.path_to_tensor(semihardtriplet.positive,self.device,False)
negative_t = self.path_to_tensor(semihardtriplet.negative,self.device,False)
return anchor_t,positive_t,negative_t
def path_to_tensor(self,img_path,device,check):
# img = Image.open(img_path)
try:
tensor = read_image(img_path,ImageReadMode.RGB)
except:
print("Cant read Image",img_path)
t = transforms.Compose([transforms.Resize((160,160))])
tensor = t(tensor)
if check:
tensor = tensor.unsqueeze(0)
tensor = tensor.float().to(device)
# tensor = tensor.permute(0,3,1,2)
return tensor