Data loader for Triplet loss + cross entropy loss

Hi, in my work I would like to use both triplet loss and cross entropy loss together. My dataset consists of folders. Usually I can load the image and label in the following way:

transform_train = transforms.Compose([transforms.Resize((224,224)),
                                      transforms.RandomHorizontalFlip(),
                                      transforms.RandomAffine(0, shear=10, scale=(0.8,1.2)),
                                      transforms.ColorJitter(brightness=1, contrast=1, saturation=1),
                                      transforms.ToTensor(),
                                      transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
                               ])


transform = transforms.Compose([transforms.Resize((224,224)),
                               transforms.ToTensor(),
                               transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
                               ])

train_dataset = datasets.ImageFolder('.././data/flower-photos/train', transform=transform_train)
val_dataset = datasets.ImageFolder('.././data/flower-photos/test', transform=transform)

train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=batch_size, shuffle=True)
val_loader = torch.utils.data.DataLoader(val_dataset, batch_size = batch_size, shuffle=False)

I need to return anchor_img, positive_img, negative_img, anchor_label. How can I do that? Thanks in advanced.

You could create a custom Dataset as described e.g. here.