Hi, unfortunately I can’t came up with a reason why your DataLoader omits the batch size dimension. I thought about the tuple unpacking part in your training script.



 hanhvn:

outfit, positive_example, negative_examples = inputs # input labels go the same way as input images outfit_categories, positive_example_category, negative_examples_categories = labels


But if I try to reproduce this it returns a 1 dimension for the batch size…
((1, 3, 3, 224, 224), (1, 1, 3, 224, 224), (1, 3, 3, 224, 224))
rather than your case
((3, 3, 224, 224), (1, 3, 224, 224), (3, 3, 224, 224))

For the batch size > 1 part you could try these lines of code.
# input images is a tuple consists of (outfit imgs, positive img, negative imgs
outfit, positive_example, negative_examples = inputs

# flatten batch dimension
outfit = outfit.contiguous().flatten(end_dim=1)
positive_example = positive_example.contiguous().flatten(end_dim=1)
negative_examples = negative_examples.contiguous().flatten(end_dim=1)

# input labels go the same way as input images
outfit_categories, positive_example_category, negative_examples_categories = labels

# flatten batch dimension
outfit_categories = outfit_categories.contiguous().flatten(end_dim=1)
positive_example_category = positive_example_category.contiguous().flatten(end_dim=1)
negative_examples_categories = negative_examples_categories.contiguous().flatten(end_dim=1)

The CSANet call should work as before. However, I’m not sure if your AttentionLayer works correctly with the flattened batches. You need to make sure that the attention only consider the corresponding images of the batch.