error when tried to migrate from pretrained-bert to transformers.
Author: y8miao
Pull request: no

The code used to be:
`logits = model(input_ids, segment_ids, input_mask, labels=None)

        if OUTPUT_MODE == "classification":
            loss_fct = CrossEntropyLoss()
            loss = loss_fct(logits.view(-1, num_labels), label_ids.view(-1))
        elif OUTPUT_MODE == "regression":
            loss_fct = MSELoss()
            loss = loss_fct(logits.view(-1), label_ids.view(-1))

        if GRADIENT_ACCUMULATION_STEPS > 1:
            loss = loss / GRADIENT_ACCUMULATION_STEPS

        loss.backward()
        print("\r%f" % loss, end='')
        
        tr_loss += loss.item()
        nb_tr_examples += input_ids.size(0)
        nb_tr_steps += 1
        if (step + 1) % GRADIENT_ACCUMULATION_STEPS == 0:
            optimizer.step()
            optimizer.zero_grad()
            global_step += 1`
According to readme, I changed it into:
`output = model(input_ids,labels=num_labels)
            loss, logits = output[:2]
            if GRADIENT_ACCUMULATION_STEPS > 1:
                loss = loss / GRADIENT_ACCUMULATION_STEPS

            loss.backward()
            print("\r%f" % loss, end='')

            tr_loss += loss.item()
            nb_tr_examples += input_ids.size(0)
            nb_tr_steps += 1
            if (step + 1) % GRADIENT_ACCUMULATION_STEPS == 0:
                optimizer.step()
                optimizer.zero_grad()
                global_step += 1`
And the issue I had before was 'tuple' object has no attribute 'view'.
After the change, I'm having a similar issue that says:
`Traceback (most recent call last):
  File "C:/Users/Youchen Miao/PycharmProjects/BERT_sent3/to_feature.py", line 150, in <module>
    output = model(input_ids,labels=num_labels)
  File "C:\Users\Youchen Miao\PycharmProjects\BERT_sent2\BERT_sent3\lib\site-packages\torch\nn\modules\module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Users\Youchen Miao\PycharmProjects\BERT_sent2\BERT_sent3\lib\site-packages\pytorch_transformers\modeling_bert.py", line 985, in forward
    loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
AttributeError: 'int' object has no attribute 'view'`

Comments:
The `labels` input for the model is not the number of labels but the tensor of labels (see the docstrings and doc).

> The `labels` input for the model is not the number of labels but the tensor of labels (see the docstrings and doc).

Thank you for the answer. I'm trying to train the model to do polarity classification for google reviews, this is how the code that computes "logits" looked like before in pytorch-pretrained-bert:
`logits = model(input_ids, segment_ids, input_mask, labels=None)`
Do I do after the migration now:

`output = model(input_ids,labels=None)`
`loss, logits = output[:2]`

in order to match the similar behaviors? Thanks.
p.s. I'm new to the field, picked up the code from the street and trying to figure out how to make it work, I'm sorry if the question is dumb.

How was this solved? I have the same problem and for me : 

output = model(input_ids,labels=None)
loss, logits = output[:2]

does not solve it