microsoft / Relation-Aware-Global-Attention-Networks

We design an effective Relation-Aware Global Attention (RGA) module for CNNs to globally infer the attention.
MIT License
337 stars 65 forks source link

IndexError: min(): Expected reduction dim 1 to have non-zero size. #26

Open MaRuiXiang1201 opened 2 years ago

MaRuiXiang1201 commented 2 years ago

After I ran the 'bash ./scripts/run_rgasc_cuhk03.sh' order, the log reports error like below:

Traceback (most recent call last): File "C:\Users\24282\Desktop\RAG\main_imgreid.py", line 261, in main(parser.parse_args()) File "C:\Users\24282\Desktop\RAG\main_imgreid.py", line 178, in main trainer.train(epoch, train_loader, optimizer, random_erasing=args.random_erasing, empty_cache=args.empty_cache) File "C:\Users\24282\Desktop\RAG\reid\img_trainers.py", line 43, in train loss, all_loss, prec1 = self._forward(ori_inputs, targets) File "C:\Users\24282\Desktop\RAG\reid\img_trainers.py", line 94, in _forward loss_tri = self.criterion[1](outputs[0], targets) File "C:\Users\24282\Desktop\RAG\reid\loss\loss_set.py", line 133, in call dist_ap, dist_an = hard_example_mining( File "C:\Users\24282\Desktop\RAG\reid\loss\loss_set.py", line 86, in hard_example_mining dist_an, relative_n_inds = torch.min( IndexError: min(): Expected reduction dim 1 to have non-zero size.

I checked the 'loss_set.py', the logic is reasonable. I couldn't figure out why there is such an 'IndexError', have any one met the same problem before? Please Help!

vampire-brook commented 2 years ago

I also meet such error, can you tell me how to fix it?

Traceback (most recent call last): File "D:\PyCharm_projects\deepLearningProjects\PresonReID\Relation-Aware-Global-Attention-Networks-master\main_imgreid.py", line 276, in main(parser.parse_args()) File "D:\PyCharm_projects\deepLearningProjects\PresonReID\Relation-Aware-Global-Attention-Networks-master\main_imgreid.py", line 193, in main trainer.train(epoch, train_loader, optimizer, random_erasing=args.random_erasing, empty_cache=args.empty_cache) File "D:\PyCharm_projects\deepLearningProjects\PresonReID\Relation-Aware-Global-Attention-Networks-master\reid\img_trainers.py", line 43, in train loss, all_loss, prec1 = self._forward(ori_inputs, targets) File "D:\PyCharm_projects\deepLearningProjects\PresonReID\Relation-Aware-Global-Attention-Networks-master\reid\img_trainers.py", line 94, in _forward loss_tri = self.criterion[1](outputs[0], targets) File "D:\PyCharm_projects\deepLearningProjects\PresonReID\Relation-Aware-Global-Attention-Networks-master\reid\loss\loss_set.py", line 133, in call dist_ap, dist_an = hard_example_mining( File "D:\PyCharm_projects\deepLearningProjects\PresonReID\Relation-Aware-Global-Attention-Networks-master\reid\loss\loss_set.py", line 86, in hard_example_mining dist_an, relative_n_inds = torch.min( IndexError: min(): Expected reduction dim 1 to have non-zero size.

Process finished with exit code 1

duandakai123 commented 1 year ago

= torch.min( IndexError: min(): Expected reduction dim 1 to have non-zero size.

解决了吗

861482002 commented 10 months ago

你需要把--num-instances和--batch-size设置清楚,其中batch-size必须是num-instances的大于1的整数倍,就解决问题了 其中--num-instances的描述中也提到了"each minibatch consist of " "(batch_size // num_instances) identities, and " "each identity has num_instances instances, " "default: 4")