Hi @ptrblck ,
Please could you explain in brief why these error occurs ?
Also what are the different case scenario these cases occurs , in simple codes?
Thankyou for answer in advance 
I had got same error but got no idea where could it occur


Summary
model = Classifier()
criterion = nn.NLLLoss()
optimizer = optim.Adam(model.parameters(), lr=0.003)
epochs = 30
steps = 0
train_losses, test_losses = [], []
for e in range(epochs):
running_loss = 0
for images, labels in trainloader:
    optimizer.zero_grad()
    
    log_ps = model(images)
    loss = criterion(log_ps, labels)
    loss.backward()
    optimizer.step()
    
    running_loss += loss.item()
    
else: #after each loop complete
    test_loss = 0
    train_loss = 0
    
    ## TODO: Implement the validation pass and print out the validation accuracy
    with torch.no_grad():
        for images, labes in testloader:
            log_ps  = model(images)
            test_loss += criterion(log_ps, labels) #update test loss
            
            ps = torch.exp(log_ps) #actual probs
            top_p, top_class = ps.topk(1, dim=1) #gives actual predicted classes
            equals = top_class == labels.view(*top_class.shape) #whether predicted class match with actual class
            accuracy += torch.mean(equals.type(torch.FloatTensor))
    train_losses.append(running_loss/len(trainloader))
    test_losses.append(test_loss/len(testloader))