Res2Net / Res2Net-PretrainedModels

(ImageNet pretrained models) The official pytorch implemention of the TPAMI paper "Res2Net: A New Multi-scale Backbone Architecture"
https://mmcheng.net/res2net/
1.07k stars 215 forks source link

Input dimension doesn't match #46

Closed ZangHuanyu closed 2 years ago

ZangHuanyu commented 4 years ago

Hi

I stoped here when I using the code from https://github.com/Res2Net/Res2Net-ImageNet-Training I got error as:

` Epoch: [0][210/225] Time 0.167 (0.280) Data 0.037 (0.042) Loss 2.6880 (4.3539) Prec@1 17.969 (21.686) Prec@5 85.938 (83.897) Epoch: [0][220/225] Time 0.170 (0.275) Data 0.030 (0.042) Loss 2.6971 (4.2777) Prec@1 28.906 (21.826) Prec@5 88.281 (83.993) Traceback (most recent call last): File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 378, in main() File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 215, in main prec1, prec5 = validate(PublicTestloader, model.cuda(), criterion, epoch) File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 301, in validate output = model(input) File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 550, in call result = self.forward(*input, *kwargs) File "D:\Github_code\Res2Net_ImageNet\res2net_pami\res2net.py", line 143, in forward x = self.conv1(x) File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 550, in call result = self.forward(input, **kwargs) File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 353, in forward return self._conv_forward(input, self.weight) File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 350, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 3, 7, 7], but got 5-dimensional input of size [128, 10, 3, 44, 44] instead

` The dataset I'm using is FER2013, the biggest change I have made is "train_loader" and "val_loader". Can author or any friends help me? Any comments are appreciated.

gasvn commented 4 years ago

Please check the input shape of your dataloader.

ZangHuanyu commented 4 years ago

Please check the input shape of your dataloader.

Thanks a lot, I just figure it out that's because I use "tencrop", which got new parameter 10.

I got one more error which is: Epoch: [0][210/225] Time 0.197 (0.197) Data 0.035 (0.034) Loss 2.8036 (4.5181) Prec@1 14.844 (21.738) Prec@5 91.406 (83.527) Epoch: [0][220/225] Time 0.196 (0.197) Data 0.035 (0.034) Loss 3.0783 (4.4549) Prec@1 12.500 (21.550) Prec@5 79.688 (83.488) Traceback (most recent call last): File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 378, in main() File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 215, in main prec1, prec5 = validate(PublicTestloader, model.cuda(), optimizer, epoch) File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 295, in validate for i, (input, target) in enumerate(PublicTestloader): File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 345, in next data = self._next_data() File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 385, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\zhy34\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Github_code\Res2Net_ImageNet\res2net_pami\fer.py", line 83, in getitem img = self.transform(img) File "C:\Users\zhy34\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py", line 61, in call img = t(img) File "C:\Users\zhy34\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py", line 313, in call return self.lambd(img) File "D:/Github_code/Res2Net_ImageNet/res2net_pami/main.py", line 96, in transforms.Lambda(lambda crops: torch.stack([transforms.ToTensor()(crop) for crop in crops])), TypeError: 'Image' object is not iterable

Appreciated if any suggestions!

gasvn commented 3 years ago

Have you solved your problem?