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

Size mismatch error on Resnet at quantization stage #7

Open
pgadosey opened this issue Apr 3, 2018 · 2 comments
Open

Size mismatch error on Resnet at quantization stage #7

pgadosey opened this issue Apr 3, 2018 · 2 comments

Comments

@pgadosey
Copy link

pgadosey commented Apr 3, 2018

Hi,
Trying TTQ on RESNET18 but getting a runtime error. Can't seem to find what the issue is:

/home/user2/Desktop/pttq/resnet_caltech/trained-ternary-quantization-master/utils/training.pyc in train(model, loss, optimization_step_fn, train_iterator, val_iterator, n_epochs, patience, threshold, lr_scheduler)
53
54 batch_loss, batch_accuracy, batch_top5_accuracy = optimization_step_fn(
---> 55 model, loss, x_batch, y_batch
56 )
57 running_loss += batch_loss

in optimization_step_fn(model, loss, x_batch, y_batch)

/home/user2/Desktop/pttq/resnet_caltech/trained-ternary-quantization-master/utils/quantization.py in optimization_step(model, loss, x_batch, y_batch, optimizer_list, t)
94
95 # get modified grads
---> 96 k_fp_grad, w_p_grad, w_n_grad = get_grads(k.grad.data, k_fp.data, w_p, w_n, t)
97
98 # grad for full precision kernel

/home/user2/Desktop/pttq/resnet_caltech/trained-ternary-quantization-master/utils/quantization.py in get_grads(kernel_grad, kernel, w_p, w_n, t)
39 c = torch.ones(kernel.size()).cuda() - a - b
40 # scaled kernel grad and grads for scaling factors (w_p, w_n)
---> 41 return w_pakernel_grad + w_nbkernel_grad + 1.0ckernel_grad,
42 (akernel_grad).sum(), (bkernel_grad).sum()
43

/usr/local/lib/python2.7/dist-packages/torch/tensor.pyc in mul(self, other)
319
320 def mul(self, other):
--> 321 return self.mul(other)
322 rmul = mul
323

RuntimeError: invalid argument 3: sizes do not match at /pytorch/torch/lib/THC/generated/../generic/THCTensorMathPointwise.cu:351

@pgadosey
Copy link
Author

pgadosey commented Apr 3, 2018

using the classifier weights as the parameter group to be quantized, i do not have this error but the focus is to quantize the conv and downsample layers which gives the above error when i attempt training

@pgadosey
Copy link
Author

pgadosey commented Apr 4, 2018

Found my error. Thanks

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

1 participant