title: Pytorch: Reshape 1d to 2d target
body: <p>Apologies if this has been answered already but I couldn't find it.</p>
  <p>I have a binary classification problem which I have been using <code>CrossEntropyLoss</code> for which expects the following input and target tensor dimensions:</p>
  <p><a href="https://i.stack.imgur.com/nIKCL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nIKCL.png" alt="CrossEntropyLoss dimension input requirements" /></a></p>
  <p>I have switched to using <code>BCEWithLogitsLoss</code> with pre-calculated class weights to address a label imbalance problem. The issue is <code>BCEWithLogitsLoss</code> expects the following dimensions:</p>
  <p><a href="https://i.stack.imgur.com/ZbkXx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZbkXx.png" alt="BCEWithLogitsLoss dimension input requirements" /></a></p>
  <p>How would I go about shaping my 1D tensor, ie. <code>tensor([[0, 0, 0,  ..., 1, 0, 0]])</code> to the shape of my inputs which is <code>(No. of X samples, 2)</code>? I have tried <code>.unsqueeze(1)</code> but this gives me <code>(#X, 1)</code>. To clarify, my input shape in the prior problem was <code>[32,2]</code> with target shape <code>[32]</code> as per above documentation and I am looking for <code>[32,2]</code> for both input and target dims.</p>