Skip to content
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: bool value of Tensor with more than one value is ambiguous #35

Closed
YachaoDong opened this issue Sep 4, 2020 · 4 comments
Closed

Comments

@YachaoDong
Copy link

您好,之前在其他机器上没有出现过这个问题,然后在学校的机器上Titan V 上运行发现这个错误,网上也搜索了好多信息,也没有解决这个问题,请问您可以帮助解决这个问题吗?非常感谢您,期待您的回复!!

Traceback (most recent call last):
File "examples/mmt_train_kmeans.py", line 294, in
main()
File "examples/mmt_train_kmeans.py", line 138, in main
main_worker(args)
File "examples/mmt_train_kmeans.py", line 234, in main_worker
is_best = (mAP_1 > best_mAP) or (mAP_2 > best_mAP)
RuntimeError: bool value of Tensor with more than one value is ambiguous

@yxgeee
Copy link
Owner

yxgeee commented Sep 4, 2020

Could you please print the value of mAP_1, best_mAP, mAP_2 and the result of mAP_1 > best_mAP?

@YachaoDong
Copy link
Author

因为我想边训练的不仅能打印mAP,也能打印rank-1,,故对此处作了更改 cmc_scores1, mAP_1 = evaluator_1_ema.evaluate(test_loader_target, dataset_target.query, dataset_target.gallery, cmc_flag=True) ,但是在之前的机器上是没有问题的。

Compute mean AP

mAP = mean_ap(distmat, query_ids, gallery_ids, query_cams, gallery_cams)
print('Mean AP: {:4.1%}'.format(mAP))           # 这个地方的mAP是对的

if (not cmc_flag):
    return mAP

cmc_configs = {
    'market1501': dict(separate_camera_set=False,
                       single_gallery_shot=False,
                       first_match_break=True)
            }
cmc_scores = {name: cmc(distmat, query_ids, gallery_ids,
                        query_cams, gallery_cams, **params)
              for name, params in cmc_configs.items()}

print('CMC Scores:')
for k in cmc_topk:
    print('  top-{:<4}{:12.1%}'
          .format(k,
                  cmc_scores['market1501'][k-1]))
return cmc_scores['market1501'][0], mAP   # 这个地方的mAP就变成了多维向量,貌似没有作均值处理

@YachaoDong
Copy link
Author

Could you please print the value of mAP_1, best_mAP, mAP_2 and the result of mAP_1 > best_mAP?

您好,可能由于自己迁移代码的时候有的地方没改,return 返回未接收正确的参数,我会将这个问题自己关闭。
非常感觉您能秒回,帮助解决问题,太敬业了,非常感谢!

@YachaoDong
Copy link
Author

Could you please print the value of mAP_1, best_mAP, mAP_2 and the result of mAP_1 > best_mAP?

您可以把这个issues删除了!非常感谢您~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants