title: Pytorch inputs for nn.CrossEntropyLoss()
body: <p>I am trying to perform a Logistic Regression in PyTorch on a simple 0,1 labelled dataset. The criterion or loss is defined as: <code>criterion = nn.CrossEntropyLoss()</code>. The model is: <code>model = LogisticRegression(1,2)</code></p>
  
  <p>I have a data point which is a pair: <code>dat = (-3.5, 0)</code>, the first element is the datapoint and the second is the corresponding label.<br/>
  Then I convert the first element of the input to a tensor: <code>tensor_input = torch.Tensor([dat[0]])</code>.<br/>
  Then I apply the model to the tensor_input: <code>outputs = model(tensor_input)</code>.<br/>
  Then I convert the label to a tensor: <code>tensor_label = torch.Tensor([dat[1]])</code>.<br/>
  Now, when I try to do this, the thing breaks: <code>loss = criterion(outputs, tensor_label)</code>. It gives and error: <code>RuntimeError: Dimension out of range (expected to be in range of [-1, 0], but got 1)</code></p>
  
  <pre><code>import torch
  import torch.nn as nn
  
  class LogisticRegression(nn.Module):
      def __init__(self, input_size, num_classes):
          super(LogisticRegression, self).__init__()
          self.linear = nn.Linear(input_size, num_classes) 
  
      def forward(self, x):
          out = self.linear(x)
          return out
  
  model = LogisticRegression(1,2)
  criterion = nn.CrossEntropyLoss()
  dat = (-3.5,0)
  tensor_input = torch.Tensor([dat[0]])
  outputs = binary_model(tensor_input)
  tensor_label = torch.Tensor([dat[1]])
  loss = criterion(outputs, tensor_label)
  </code></pre>
  
  <p>I can't for the life of me figure it out.</p>