_宠幸_ 2022-09-09 09:46 采纳率: 75%
浏览 2090
已结题

ValueError: too many values to unpack (expected 2)

feat_pool, feat_fc = net(input, input, test_mode[1])
ValueError: too many values to unpack (expected 2)

with torch.no_grad():
    for batch_idx, (input, label ) in enumerate(query_loader):
        batch_num = input.size(0)
        input = Variable(input.cuda())
        feat_pool, feat_fc = net(input, input, test_mode[1])
        query_feat_pool[ptr:ptr+batch_num,: ] = feat_pool.detach().cpu().numpy()
        query_feat_fc[ptr:ptr+batch_num,: ]   = feat_fc.detach().cpu().numpy()
        ptr = ptr + batch_num         
print('Extracting Time:\t {:.3f}'.format(time.time()-start))
return query_feat_pool, query_feat_fc

其中query_loader = data.DataLoader(queryset, batch_size=args.test_batch, shuffle=False, num_workers=0)

Traceback (most recent call last):
File "E:/韩志忠学习/海军21code/DGTL-for-VT-ReID-main/test.py", line 266, in
query_feat_pool, query_feat_fc = extract_query_feat(query_loader)
File "E:/韩志忠学习/海军21code/DGTL-for-VT-ReID-main/test.py", line 156, in extract_query_feat
feat_pool, feat_fc = net(input, input, test_mode[1])
ValueError: too many values to unpack (expected 2)

  • 写回答

4条回答 默认 最新

  • 怀念不必想念 2022-09-09 10:07
    关注

    eat_pool, feat_fc = net(input, input, test_mode[1])这段话的
    net函数的返回值给多了,看下net的return几个变量

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 9月17日
  • 已采纳回答 9月9日
  • 创建了问题 9月9日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度