Check which of the objects creates the indexing error, print its shape as well as the corresponding index, and make sure the index is inside the bounds. I don’t know how correct and class_correct are created and thus can only speculate.