ronghuaiyang / arcface-pytorch

1.74k stars 392 forks source link

Tensor size mismatch #26

Closed zhangjiatao closed 5 years ago

zhangjiatao commented 5 years ago

I try to test the pre-trained model resnet18_110.pth in lfw dataset, and the test_batch_size = 16 . but i got a mismatch error in the 'resnet.py' like this:

Traceback (most recent call last):
  File "test.py", line 171, in <module>
    lfw_test(model, img_paths, identity_list, opt.lfw_test_list, opt.test_batch_size)
  File "test.py", line 141, in lfw_test
    features, cnt = get_featurs(model, img_paths, batch_size=batch_size)
  File "test.py", line 65, in get_featurs
    output = model(data)
  File "/Users/zhangjiatao/anaconda3/envs/new_python/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/zhangjiatao/anaconda3/envs/new_python/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 138, in forward
    return self.module(*inputs, **kwargs)
  File "/Users/zhangjiatao/anaconda3/envs/new_python/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/zhangjiatao/Documents/MyProject/PingAn/arcface-pytorch/models/resnet.py", line 220, in forward
    x = self.fc5(x)
  File "/Users/zhangjiatao/anaconda3/envs/new_python/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/Users/zhangjiatao/anaconda3/envs/new_python/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 67, in forward
    return F.linear(input, self.weight, self.bias)
  File "/Users/zhangjiatao/anaconda3/envs/new_python/lib/python3.6/site-packages/torch/nn/functional.py", line 1352, in linear
    ret = torch.addmm(torch.jit._unwrap_optional(bias), input, weight.t())
RuntimeError: size mismatch, m1: [16 x 131072], m2: [32768 x 512] at /Users/administrator/nightlies/pytorch-1.0.0/wheel_build_dirs/conda_3.6/conda/conda-bld/pytorch_1544137972173/work/aten/src/TH/generic/THTensorMath.cpp:940

the error occur in x = self.fc5(x) in Class ResNetFace, do you have any idea?

zhangjiatao commented 5 years ago

i get it, my image size is 250 250, but the model need 128 128