title: ValueError: Target size (torch.Size([64, 3])) must be the same as input size (torch.Size([32, 3]))
body: <p>Reference github: <a href="https://github.com/kaushaltrivedi/fast-bert" rel="nofollow noreferrer">fast-bert</a></p>
  <p>I used to run the following notebook to predict the multi label classification using Bert model that means I don't need GPU driver instead I can use CPU memory,
  here is the reference for jupyter notebook <a href="https://github.com/kaushaltrivedi/fast-bert/blob/master/sample_notebooks/new-toxic-multilabel.ipynb" rel="nofollow noreferrer">multilabel</a></p>
  <p>It's not the memory issue, How to resolve this error?</p>
  <p>While increasing CPU with RAM size, target size also getting increasing,</p>
  <blockquote>
  <p>I choose n1-standard-4 (6 vCPUs, 26 GB memory) machine type.</p>
  </blockquote>
  <p><strong>Sample code:</strong></p>
  <p>I have removed this peace of code I use '<strong>cpu</strong>' instead of '<strong>cuda</strong>'</p>
  <pre><code>device = torch.device('cuda')
  if torch.cuda.device_count() &gt; 1:
      args.multi_gpu = True
  else:
      args.multi_gpu = False
  </code></pre>
  <p>to</p>
  <pre><code>torch.device('cpu')
  </code></pre>
  <p><strong>Error Logs:</strong></p>
  <pre><code>Traceback (most recent call last):-------------------------------------------------------------| 0.00% [0/63 00:00&lt;00:00]
    File &quot;bert/run.py&quot;, line 146, in &lt;module&gt;
      learner.fit(args.num_train_epochs, args.learning_rate, validate=True)
    File &quot;/home/pt4_gcp/.local/lib/python3.7/site-packages/fast_bert/learner_cls.py&quot;, line 397, in fit
      outputs = self.model(**inputs)
    File &quot;/home/pt4_gcp/.local/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
      result = self.forward(*input, **kwargs)
    File &quot;/home/pt4_gcp/.local/lib/python3.7/site-packages/fast_bert/modeling.py&quot;, line 205, in forward
      logits.view(-1, self.num_labels), labels.view(-1, self.num_labels)
    File &quot;/home/pt4_gcp/.local/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
      result = self.forward(*input, **kwargs)
    File &quot;/home/pt4_gcp/.local/lib/python3.7/site-packages/torch/nn/modules/loss.py&quot;, line 617, in forward
      reduction=self.reduction)
    File &quot;/home/pt4_gcp/.local/lib/python3.7/site-packages/torch/nn/functional.py&quot;, line 2433, in binary_cross_entropy_with_logits
      raise ValueError(&quot;Target size ({}) must be the same as input size ({})&quot;.format(target.size(), input.size()))
  ValueError: Target size (torch.Size([64, 3])) must be the same as input size (torch.Size([32, 3]))
  </code></pre>