title: PyTorch Linear layer input dimension mismatch
body: <p>Im getting this error when passing the input data to the Linear (Fully Connected Layer) in PyTorch:</p>
  
  <pre><code>matrices expected, got 4D, 2D tensors
  </code></pre>
  
  <p>I fully understand the problem since the input data has a shape (N,C,H,W) (from a Convolutional+MaxPool layer) where:</p>
  
  <ul>
  <li>N: Data Samples</li>
  <li>C: Channels of the data</li>
  <li>H,W: Height and Width</li>
  </ul>
  
  <p>Nevertheless I was expecting PyTorch to do the "reshaping" of the data form:</p>
  
  <ul>
  <li>[ N , D1,...Dn] --> [ N, D] where D = D1*D2*....Dn</li>
  </ul>
  
  <p>I try to reshape the Variable.data, but I've read that this approach is not recommended since the gradients will conserve the previous shape, and that in general you should not mutate a Variable.data shape.</p>
  
  <p>I am pretty sure there is a simple solution that goes along with the framework, but i haven't find it.</p>
  
  <p>Is there a good solution for this?</p>
  
  <p>PD: The Fully connected layer has as input size the value C * H * W</p>