Skip to content Skip to sidebar Skip to footer

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

In the code below: model_ft.eval() test_data, test_target = image_datasets['train'][idx] test_data = test_data.cuda() #test_target = test_target.cuda() test_tar

Solution 1:

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)

Post a Comment for "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"