Keyerror when for loop dataloader

When I use Dataloader, It occurs error below:

I don’t know why the error occurs. Is there any problem raising this error?

Thank you

Could you use num_workers=0 and rerun the script?
If that’s working, could you iterate the Dataset directly without wrapping it into a DataLoader?

PS: It’s better to post code directly by wrapping it into three backticks ```, as it makes debugging easier. :wink:

Thank ptrblc!
When num_workers=0 is set, the problem is solved.
And as you mentione, I iterated the Dataset directly with no errors

Thank you for your reply!!

That’s weird, as the DataLoader seems to raise this error even though you can successfully iterate the Dataset.
Are you somehow manipulating the dataset inside your training loop?