C2D
C2D copied to clipboard
problem running the code
Hi I try to do a benchmark on cifar100 with 80% noisy labels with resnet18.
This is the command
python3 main_cifar.py --r 0.80 --lambda_u 500 --dataset cifar100 --p_threshold 0.03 --data_path ./cifar-100 --experiment-name simclr_resnet18 --method reg --net resnet18 --batch_size 32
but at a random epoch it throws this
File "main_cifar.py", line 174, in main
run_train_loop(net1, optimizer1, sched1, net2, optimizer2, sched2, criterion, CEloss, CE, loader, args.p_threshold,
File "/home/nikkokks/labelr/C2D/train_cifar.py", line 148, in run_train_loop
train(epoch, net1, net2, criterion, optimizer1, labeled_trainloader, unlabeled_trainloader, lambda_u,
File "/home/nikkokks/labelr/C2D/train.py", line 66, in train
targets_x, targets_u = co_guess(net, net2, inputs_x, inputs_u, inputs_x2, inputs_u2, w_x, labels_x, T,
File "/home/nikkokks/labelr/C2D/train.py", line 25, in co_guess
outputs_x = net(inputs_x)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torchvision/models/resnet.py", line 285, in forward
return self._forward_impl(x)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torchvision/models/resnet.py", line 276, in _forward_impl
x = self.layer4(x)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/modules/container.py", line 217, in forward
input = module(input)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torchvision/models/resnet.py", line 93, in forward
out = self.bn1(out)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/modules/batchnorm.py", line 171, in forward
return F.batch_norm(
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/functional.py", line 2448, in batch_norm
_verify_batch_size(input.size())
File "/home/nikkokks/.local/lib/python3.8/site-packages/torch/nn/functional.py", line 2416, in _verify_batch_size
raise ValueError("Expected more than 1 value per channel when training, got input size {}".format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 512, 1, 1])
I suppose this is due to the last batch_size.
Do you have a better solution than activating drop_last = True ?