cfzd / FcaNet

FcaNet: Frequency Channel Attention Networks
MIT License
503 stars 100 forks source link

跑您的模型的时候遇到的一些问题 #13

Closed LihuiNb closed 3 years ago

LihuiNb commented 3 years ago

您好,非常欣赏您的idea,所以尝试跑一下您的分类模型。 我下载了ImageNet2012数据集之后,尝试启动您的模型,遇到了以下问题,想请教一下是否我的哪些设置出错了?

错误信息如下: Traceback (most recent call last): File "main.py", line 643, in main() File "main.py", line 389, in main avg_train_time = train(train_loader, model, criterion, optimizer, epoch, logger, scheduler) File "main.py", line 471, in train prec1, prec5 = accuracy(output.data, target, topk=(1, 5)) File "main.py", line 631, in accuracy correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

cfzd commented 3 years ago

@LihuiNb 您好,我没有遇到过这种问题,不过看报错信息的话可以这样修改: correct_k = correct[:k].view(-1).float().sum(0, keepdim=True) 改为 correct_k = correct[:k].contiguous().view(-1).float().sum(0, keepdim=True)

LihuiNb commented 3 years ago

谢谢,您非常专业,问题已解决。