Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distillation RuntimeError #232

Open
NeelKanwal opened this issue Aug 31, 2022 · 1 comment
Open

Distillation RuntimeError #232

NeelKanwal opened this issue Aug 31, 2022 · 1 comment

Comments

@NeelKanwal
Copy link

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

@krrishdholakia
Copy link

krrishdholakia commented Dec 14, 2022

@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/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants