Error during training

Hi all,
I am using the mean of features for training the network. It generates the same error, sometimes after 4 epochs, sometimes after 10 epochs or 19 epochs. I ve faced this type of probles first time. Any help in this regard will be appreciated.

Error after 19 epochs of training:

File “main.py”, line 510, in train
feature_mean_stack[idx]= torch.stack([feats[idx]],dim=0).cuda(non_blocking=True)
KeyError: 6

Here 6 is the index of class.

Cheers

Based on the error message it seems that feats does not always have the desired size as the indexing operation fails. I don’t know, how feats is initialized, but you would have to make sure it’s not depending on e.g. the model predictions.