Solved by wfondrie in post #4 
              
              
                Check the dimensions of your output layer (looks like fc2). In this case, I think the dimensions need to match the number of classes. 
Try making self.fc2 = nn.Linear(500, 16) for 16 classes and see if that fixes it.