shirakawas / ASNG-NAS

Adaptive Stochastic Natural Gradient Method for One-Shot Neural Architecture Search
MIT License
88 stars 11 forks source link

RuntimeError: The size of tensor a (80) must match the size of tensor b (78) at non-singleton dimension 2 #1

Open duoduoda opened 4 years ago

duoduoda commented 4 years ago

Hi, thanks for your work. I am learning this project. When I run your codes,I hava this problem:

Traceback (most recent call last): File "main_inpainting_cat.py", line 181, in train_ite=train_ite, retrain_ite=retrain_ite, out_dir=out_dir) File "main_inpainting_cat.py", line 109, in experiment out_model=prefix + 'trained_model.pt', log_file=prefix + 'train_log.csv') File "C:\Users\dw8855\PycharmProjects\test\ASNG-NAS-master-yuan\inpainting\inpainting_cat\train.py", line 68, in arch_searchvalid Y, = model(corrupt_func(X), stochastic=True) File "D:\anaconda\anaconda\lib\site-packages\torch\nn\modules\module.py", line 477, in call result = self.forward(*input, *kwargs) File "C:\Users\dw8855\PycharmProjects\test\ASNG-NAS-master-yuan\inpainting\inpainting_cat\cae_model.py", line 75, in forward h = self.forward_as(M, x) File "C:\Users\dw8855\PycharmProjects\test\ASNG-NAS-master-yuan\inpainting\inpainting_cat\cae_model.py", line 107, in forward_as h = f[k + conv_num](h, xx, ch_num=ch_num) File "D:\anaconda\anaconda\lib\site-packages\torch\nn\modules\module.py", line 477, in call result = self.forward(input, **kwargs) File "C:\Users\dw8855\PycharmProjects\test\ASNG-NAS-master-yuan\inpainting\common\operations.py", line 54, in forward return self.relu(x + h) RuntimeError: The size of tensor a (80) must match the size of tensor b (78) at non-singleton dimension 2

Looking forward to your reply.

shirakawas commented 4 years ago

Maybe, the error is caused by an unsupported input image size. The current code only supports the image size of the power of 2 (2^n). To accept other image sizes, you need to modify the code for convolution and deconvolution layers and equalize the image sizes of corresponding layers.