Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一个bug:IndexError: index 2 is out of range #11

Open
starsky68 opened this issue Nov 9, 2020 · 0 comments
Open

一个bug:IndexError: index 2 is out of range #11

starsky68 opened this issue Nov 9, 2020 · 0 comments

Comments

@starsky68
Copy link

starsky68 commented Nov 9, 2020

假设训练5个类,在训练的时候每一帧图像对应的标签,类别号如果是0-4中间有缺失,比如标签中只有0类和2类,就会出现最后一个类别号越界的错误:
以下是我打印的一个models.py的第332行的cls_id, nID,以及334行的self.id_classifiers,
0 3==========
2 3==========
ModuleList(
(0): Linear(in_features=128, out_features=3, bias=True)
(1): Linear(in_features=128, out_features=3, bias=True)
) 33333333333333
Model Summary: 91 layers, 6.67257e+06 parameters, 6.67257e+06 gradients
Caching labels (1 found, 0 missing, 0 empty, 0 duplicate, for 1 images): 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 979.06it/s]
Image sizes 384 - 832 train, 768 test
Using 0 dataloader workers
Starting training for 100 epochs...

 Epoch   gpu_mem      GIoU       obj       cls      reid     total   targets  img_size

0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 660, in
train() # train normally
File "train.py", line 452, in train
loss, loss_items = compute_loss_no_upsample(pred, reid_feat_out, targets, track_ids, model)
File "/home/11/YOLOV4_MCMOT-master/utils/utils.py", line 501, in compute_loss_no_upsample
fc_preds = model.id_classifiers[cls_id].forward(id_vects).contiguous()
File "/home/11/.local/lib/python3.8/site-packages/torch/nn/modules/container.py", line 164, in getitem
return self._modules[self._get_abs_string_index(idx)]
File "/home/11/.local/lib/python3.8/site-packages/torch/nn/modules/container.py", line 154, in _get_abs_string_index
raise IndexError('index {} is out of range'.format(idx))
IndexError: index 2 is out of range

该处是不是应该修改一下,以适应上述中的情况。
@CaptainEven

@starsky68 starsky68 changed the title 一个bug 一个bug:IndexError: index 2 is out of range Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant