I think it’s okay for ignore index to be positive. However, if your output tensor has k channels, then the loss function expects indices from 0 to k-1 (because it will use these to index into the output tensor).