wujiyang / Face_Pytorch

face recognition algorithms in pytorch framework, including arcface, cosface, sphereface and so on
Apache License 2.0
808 stars 156 forks source link

RuntimeError: size mismatch #17

Open Sotatek-HoangTran opened 5 years ago

Sotatek-HoangTran commented 5 years ago

I got an error: RuntimeError: size mismatch, m1: [1 x 32768], m2: [25088 x 512] at /opt/conda/conda-bld/pytorch_1549628766161/work/aten/src/THC/generic/THCTensorMathBlas.cu:266. My backbone is Res50_IR. I dont know how to fix this. What should i do ?

wujiyang commented 5 years ago

Did you use the input size of 112*112 ? If not, you should modify the size of last convolutional feature map.

Sotatek-HoangTran commented 5 years ago

yes, my dataset's input size is 112*112

wujiyang commented 5 years ago

25088 = 512 7 7; 32768 = 512 8 8; It seems that you are using 120 * 120 input. Can you give more details on the error message ?

Sotatek-HoangTran commented 5 years ago

Sorry, my bad. My input size is not 112112. but i got another issue: `Traceback (most recent call last): File "train.py", line 235, in train(args) File "train.py", line 124, in train raw_logits = net(img) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(input, kwargs) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 141, in forward return self.module(*inputs[0], *kwargs[0]) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(input, kwargs) File "/home/sotatek/hoang.tran/Face_Pytorch/backbone/cbam.py", line 281, in forward x = self.output_layer(x) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, *kwargs) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/modules/container.py", line 92, in forward input = module(input) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(input, **kwargs) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 76, in forward exponential_average_factor, self.eps) File "/home/sotatek/anaconda2/envs/hoangtran/lib/python3.6/site-packages/torch/nn/functional.py", line 1619, in batch_norm 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]) ` Thank you for spending time with me !