text: 
  
  TITLE
  RuntimeError: The size of tensor a (128) must match the size of tensor b (32) at non-singleton dimension 1
  
  COMMENTS
  4
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  # 📚 Migration from pytorch-pretrained-bert to transfomers
  
  ## Information
  
  <!-- Important information -->
  
  Model I am using (Bert, XLNet ...): bert
  
  Language I am using the model on (English, Chinese ...):english
  
  The problem arises when using:
  * [ ] the official example scripts: (give details below)
  
  when I use this model my code work correctly
  
  ```py
  from pytorch_pretrained_bert.modeling import BertForSequenceClassification
  model = BertForSequenceClassification.from_pretrained(args.bert_model, num_labels=num_labels)
  ```
  but when I change to below I get the error, what Is the problem
  
  ```py
  from transformers import BertTokenizer, BertForSequenceClassification
  model = BertForSequenceClassification.from_pretrained('bert-base-cased', num_labels=num_labels)
  ```
  
  ```
  error :
  Traceback (most recent call last):
    File "paragraph_selection/train.py", line 293, in <module>
      loss = model(input_ids, segment_ids, input_mask, label_ids)
    File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
      result = self.forward(*input, **kwargs)
    File "/usr/local/lib/python3.6/dist-packages/transformers/models/bert/modeling_bert.py", line 1375, in forward
      return_dict=return_dict,
    File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
      result = self.forward(*input, **kwargs)
    File "/usr/local/lib/python3.6/dist-packages/transformers/models/bert/modeling_bert.py", line 862, in forward
      input_ids=input_ids, position_ids=position_ids, token_type_ids=token_type_ids, inputs_embeds=inputs_embeds
    File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
      result = self.forward(*input, **kwargs)
    File "/usr/local/lib/python3.6/dist-packages/transformers/models/bert/modeling_bert.py", line 204, in forward
      embeddings += position_embeddings
  RuntimeError: The size of tensor a (128) must match the size of tensor b (32) at non-singleton dimension 1
  ```
    
  * [ ] my own modified scripts: (give details below)
  
  The tasks I am working on is:
  * [ ] an official GLUE/SQUaD task: (give the name)
  * [ ] my own task or dataset: (give details below)
  
  ## Details
  
  <!-- A clear and concise description of the migration issue.
      If you have code snippets, please provide it here as well.
      Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
      Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.
      -->
  
  ## Environment info
  colab
   
  - `transformers` version:
  - Platform:
  - Python version:
  - PyTorch version (GPU?):
  - Tensorflow version (GPU?):
  - Using GPU in script?:
  - Using distributed or parallel set-up in script?:
  
  <!-- IMPORTANT: which version of the former library do you use? -->
  * `pytorch-transformers` or `pytorch-pretrained-bert` version (or branch):
  
  
  ## Checklist
  
  - [ ] I have read the migration guide in the readme.
   ([pytorch-transformers](https://github.com/huggingface/transformers#migrating-from-pytorch-transformers-to-transformers);
    [pytorch-pretrained-bert](https://github.com/huggingface/transformers#migrating-from-pytorch-pretrained-bert-to-transformers))
  - [ ] I checked if a related official extension example runs on my machine.
  