title: Shape of target and predictions tensors in PyTorch loss functions
body: <p>I am confused with the input shapes for tensors in <code>nn.CrossEntropyLoss</code>.
  I am trying to implement a simple autoencoder for text sequences. The core of my problem can be illustrated by the following code</p>
  
  <pre><code>predictions = torch.rand(2, 3, 4)
  target = torch.rand(2, 3)
  print(predictions.shape)
  print(target.shape)
  nn.CrossEntropyLoss(predictions.transpose(1, 2), target)
  </code></pre>
  
  <p>In my case predictions has the shape <code>(time_step, batch_size, vocabulary_size)</code> while target has the shape <code>(time_step, batch_size)</code>. Next I am transposing the predictions as per <a href="https://pytorch.org/docs/master/generated/torch.nn.CrossEntropyLoss.html#torch.nn.CrossEntropyLoss" rel="nofollow noreferrer">description</a> which says that the second dimension of predictions should be the number of classes - vocabulary_size in my case. The code returns an error <code>RuntimeError: bool value of Tensor with more than one value is ambiguous</code>. Could someone please enlighten me how to use the damn thing? Thank you in advance!</p>