vit-pytorch icon indicating copy to clipboard operation
vit-pytorch copied to clipboard

Distillation RuntimeError

Open NeelKanwal opened this issue 2 years ago • 1 comments

Hi,

I am using distiller where teacher network is resnet34.

I am getting this error while training the model:

distiller(data, target) Traceback (most recent call last): File "/home/neel/miniconda3/envs/process/lib/python3.7/code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "/home/neel/miniconda3/envs/process/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/neel/miniconda3/envs/process/lib/python3.7/site-packages/vit_pytorch/distill.py", line 146, in forward reduction = 'batchmean') File "/home/neel/miniconda3/envs/process/lib/python3.7/site-packages/torch/nn/functional.py", line 2916, in kl_div reduced = torch.kl_div(input, target, reduction_enum, log_target=log_target) RuntimeError: The size of tensor a (1000) must match the size of tensor b (2) at non-singleton dimension 1

the shape of my data is: torch.Size([24, 3, 224, 224]) the shape of the target is : torch.Size([24])

Is there something wrong? I am using the same instructions from the GitHub homepage. Has anyone else experienced this?

Neel

NeelKanwal avatar Aug 31 '22 09:08 NeelKanwal

@NeelKanwal Looking at this stackoverflow q around this - https://stackoverflow.com/questions/56783182/runtimeerror-the-size-of-tensor-a-133-must-match-the-size-of-tensor-b-10-at

Are you using the same dataloader for both your data and the target / could this potentially be a dataloader issue? - Clerkie (clerkie.co/)

krrishdholakia avatar Dec 14 '22 11:12 krrishdholakia