okankop/Efficient-3DCNNs

i need your help

world2025 opened this issue · 15 comments

hello ,thanks for your code ,i meet a error when i train the jester dataset, invalid argument 0: sizes of tensors must match except in dimension 0 ,got 16 and 7 in dimension 2 ,can you give me some advice ? thank you

Can you please share your parameters configuration?

Namespace(annotation_path='D:/gesture recognition/Efficient-3DCNNs-master/annotation_Jester/jester.json', arch='resnet', batch_size=19, begin_epoch=1, checkpoint=1, crop_position_in_test='c', dampening=0.9, dataset='jester', downsample=1, ft_portion='complete', groups=3, initial_scale=1.0, learning_rate=0.04, lr_patience=10, lr_steps=[40, 55, 65, 70, 200, 250], manual_seed=1, mean=[114.7748, 107.7354, 99.475], mean_dataset='activitynet', modality='RGB', model='resnet', model_depth=101, momentum=0.9, n_classes=27, n_epochs=120, n_finetune_classes=27, n_scales=5, n_threads=0, n_val_samples=3, nesterov=False, no_cuda=False, no_hflip=False, no_mean_norm=False, no_softmax_in_test=False, no_train=False, no_val=False, norm_value=1, optimizer='sgd', pretrain_path='', resnet_shortcut='B', resnext_cardinality=32, result_path='D:/gesture recognition/Efficient-3DCNNs-master/results', resume_path='', root_path='D:/gesture recognition/Efficient-3DCNNs-master/', sample_duration=16, sample_size=112, scale_in_test=1.0, scale_step=0.84089641525, scales=[1.0, 0.84089641525, 0.7071067811803005, 0.5946035574934808, 0.4999999999911653], std=[38.7568578, 37.88248729, 40.02898126], std_norm=False, store_name='jester_resnet_1.0x_RGB_16', test=False, test_subset='val', train_crop='corner', version=1.1, video_path='D:/gesture recognition/Efficient-3DCNNs-master/jester/20bn-jester-v1/', weight_decay=0.001, wide_resnet_k=2, width_mult=1.0)
D:\gesture recognition\Efficient-3DCNNs-master\models\resnet.py:145: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
m.weight = nn.init.kaiming_normal(m.weight, mode='fan_out')

i do not know how to solve it

On which line are you getting this error?

@okankop the error arose in the middle of the first epoch, in train data loader line

So you successfully started the training and this error occurred in the middle. Then I suspect there is a problem regarding dataloader or the dataset itself. It seems that for one training video, dataloader could not read 16 images and read 7 images instead, which created this error. Could you please check your dataset & dataloader and let us know if that was the issue?

you say the batchsize?

No, it is not related to batch_size. The error says there is a mismatch of dimension, 16 and 7 in dimension 7. So if you are successfully training till the middle of epoch, most probably there is a problematic video sample and when dataloader tries to laod it, this error happens.

Solution: Download the Jester dataset again.

ok ,i try it

File "", line 1, in
runfile('D:/gesture recognition/Efficient-3DCNNs-master/main.py', wdir='D:/gesture recognition/Efficient-3DCNNs-master')

File "C:\Users\78245\Anaconda3\envs\Gesture\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\Users\78245\Anaconda3\envs\Gesture\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/gesture recognition/Efficient-3DCNNs-master/main.py", line 153, in
train_logger, train_batch_logger)

File "D:\gesture recognition\Efficient-3DCNNs-master\train.py", line 23, in train_epoch
for i, (inputs, targets) in enumerate(data_loader):

File "C:\Users\78245\Anaconda3\envs\Gesture\lib\site-packages\torch\utils\data\dataloader.py", line 560, in next
batch = self.collate_fn([self.dataset[i] for i in indices])

File "C:\Users\78245\Anaconda3\envs\Gesture\lib\site-packages\torch\utils\data_utils\collate.py", line 68, in default_collate
return [default_collate(samples) for samples in transposed]

File "C:\Users\78245\Anaconda3\envs\Gesture\lib\site-packages\torch\utils\data_utils\collate.py", line 68, in
return [default_collate(samples) for samples in transposed]

File "C:\Users\78245\Anaconda3\envs\Gesture\lib\site-packages\torch\utils\data_utils\collate.py", line 43, in default_collate
return torch.stack(batch, 0, out=out)

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 16 and 3 in dimension 2 at ..\aten\src\TH/generic/THTensor.cpp:711

I find a probably reason is that the data sets have different image sizes. Resize and Crop were used when loading the training set, but they were forgotten during the test.

I believe the issue is resolved.

I face the same issue when trying to train with jestor.

@okankop can you please check ?