IndexError: index 10 is out of bounds for dimension 0 with size 10

I’ve been stuck here for a while now. Any help.
Screenshot%20from%202019-05-13%2022-24-23

1 Like

code: batch_size = 30

The last batch given by your DataLoader might be smaller, if the length of your Dataset is not divisible by the batch size without a remainder.
Try to get the current batch size inside the training loop:

for data, target in testloader:
    batch_size = data.size(0)
    ...
    for i in range(batch_size):
        ...
2 Likes

I worked perfectly!!! :grinning: Thank you!