Your last layer



 Manasvi_Varma:

self.fc3 = nn.Linear(84, 10)


has only 10 output neurons which means you classify into 10 classes.
But your targets/labels go even higher than that.



 Manasvi_Varma:

—> 13 loss = criterion(outputs, labels)


Your loss-function gets the output of your network, which classifies into 10 classes, but gets class 18 as ground-truth target/label, thats why it says:



 Manasvi_Varma:

IndexError: Target 18 is out of bounds.


Change the 10 in this line to the number of classes your dataset has.



 Manasvi_Varma:

self.fc3 = nn.Linear(84, 10)