-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: expected a non-empty list of Tensors #95
Comments
Did you change any other parameters like batch size, dataset, etc? And does the bug occur every time you run it, or does it seem random? |
This is where may cause the error and I can see the problem every time . |
Ah, yes I think it's related to the batch size and the MPerClassSampler. I have a few ideas of how to improve / fix this bug. But in the meantime, try m=2 in the MPerClassSampler. |
when I debuged the error, I found that this was caused by the function convert_to_triplets in loss_and_miner_utils.py.
when the list a1 is disjoint with the a2, the final result x will be empty to cause the error. I am confused with the meaning of the list a1 and the source of it. |
(a1, p) represents positive pairs, and (a2, n) represents negative pairs. The code is trying to convert pairs to triplets, and in order to do that, it has to find the positive and negative pairs that share a common "anchor". In other words, it needs to find the a1 and a2 that are equal to each other. The most likely reason why a1 and a2 are disjoint is because your batch size is small, which results in a small number of possible pairs. The small number of possible pairs is reduced even further by the MultiSimilarityMiner and HDCMiner. In addition to that, if your MPerClassSampler has So there's really 2 things for me to improve here, but I might not get around to it for a couple days. If you need to get your code running soon, I suggest either using a larger batch size, or using miners that are directly compatible with the losses. That means if a loss is expecting triplets, then use a triplet miner. So for example, you could replace HDCMiner with TripletMarginMiner. |
I finally fixed the bug in |
I made a separate issue for improving MPerClassSampler: #124 |
When I followed the cascaded example, I just removed the dataparallel code and met the issue.
The text was updated successfully, but these errors were encountered: