Yao-DD / S3N

86 stars 26 forks source link

Message: index 1 is out of bounds for dimension 0 with size 1 #7

Open MercuialC opened 4 years ago

MercuialC commented 4 years ago

Message: index 1 is out of bounds for dimension 0 with size 1 losses.py", line 69, in function "multi_smooth_loss" ymask = smooth_ratioymask + (1-smooth_ratio)(1-ymask)/(len(input[i][1])-1)

After ‘PYTHONWARNINGS='ignore' CUDA_VISIBLE_DEVICES=0,1 nest task run ./demo/cub_s3n.yml‘ How to deal with this problem?

catalys1 commented 3 years ago

For anyone else encountering this problem, the issue occurs when the effective batch size is 1 (which happens for CUB when using 2 GPUs on the very last validation batch). Replacing

ymask = smooth_ratio*ymask + (1-smooth_ratio)*(1-ymask)/(len(input[i][1])-1)

with

ymask = smooth_ratio*ymask + (1-smooth_ratio)*(1-ymask)/(input[i].shape[1]-1)

should fix the problem.

Yao-DD commented 3 years ago

Thank you~ I fixed the problem according to your suggestion.