Hello Milad!



 milad66:

        self.fc = nn.Linear(56 * 56 * 32, 2)        
...
        out = self.fc(out)
        return out
...
criterion = nn.CrossEntropyLoss()
...
        loss = criterion(outputs, targets)

---> 13         loss = criterion(outputs, targets)
...
IndexError: Target 3 is out of bounds.



Your last (fully-connected) layer has an output size of 2.
Therefore your model will output a tensor of shape
[batchSize, 2].  This is passed to CrossEntropyLoss,
so your targets must be a tensor of shape [batchSize]
consisting of integer class labels that range from 0 to 1.
One of your target labels has value 3, hence the error.
It appears that you are working on a classification problem.
How many classes does your problem actually have?
Best.
K. Frank