The error was probably on the way I calculated the error. For the fix check:

  
      stackoverflow.com
  
  
      
    
  

  How does one manually compute the error of the whole data set in pytorch? 16



  python, machine-learning, neural-network, conv-neural-network



  
  answered by
  
    Charlie Parker
  
  on 07:17PM - 13 Apr 18


  
  
    
    
  
  



  
    
    
    How does the Cifar10 tutorial make sure to use the test set is actually the test set if both use the same path to load both test and train? 
  
  
    I had a look at your code and it seems your error calculation does overflow. 
In this method you are calculating the error: 
def error_criterion(outputs,labels):
    max_vals, max_indices = torch.max(outputs,1)
    train_error = (max_indices != labels).sum().data[0]/max_indices.size()[0]
    return train_error

The comparision (max_indices != labels) returns a torch.ByteTensor, which can overflow using your batch size of 10000. 
Adding a .float to this line (max_indices != labels).float().sum().…