RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[3, 1, 224, 224] to have 3 channels, but got 1 channels instead

前端 未结 1 2349
死守一世寂寞
死守一世寂寞 2021-01-28 12:11

In the code below:

    model_ft.eval()
    test_data, test_target = image_datasets[\'train\'][idx]
    test_data = test_data.cuda()
    #test_target = test_targe         


        
相关标签:
1条回答
  • 2021-01-28 12:55

    Here's the fix:

    test_data, test_target = image_datasets['train'][idx]
    test_data = test_data.cuda()
    test_target = torch.tensor(test_target)
    test_target = test_target.cuda()
    test_data.unsqueeze_(0)
    test_target.unsqueeze_(0)
    output = model_ft(test_data)
    

    I had to change test_data.unsqueeze_(1) to test_data.unsqueeze_(0)

    0 讨论(0)
提交回复
热议问题