title: BERT Sequence Classification output layer using TensorFlow
body: <p>I'm very new to the Transformers library from huggingface. What I'm trying to do is make a regression of a value using BERT transformers. I have the input tokens ids and the attention masks correctly generated. Now, my problem is with the prediction output. I'm getting the logits for each token present in my input and not only one number representing my output. My configuration in the TFAutoModelForSequenceClassification object is for 1 label. What I'm doing wrong?</p>
  <pre class="lang-py prettyprint-override"><code>def bert_model():
      config = BertConfig()
      config.num_labels = 1
      encoder = TFAutoModelForSequenceClassification.from_pretrained(BASE_MODEL, config=config)
      input_ids = tf.keras.Input(shape=(300,), dtype=tf.int32, name='input_ids')
      input_attention_mask = tf.keras.Input(shape=(300,), dtype=tf.int32, name='attention_mask')
  
      output = encoder({'input_ids': input_ids, 'attention_mask': input_attention_mask})
      # output = tf.keras.layers.Dense(1)
      
      model = tf.keras.Model(inputs=[input_ids, input_attention_mask], outputs=output)
      
      optimizer = tf.keras.optimizers.Adam(lr=1e-5)
      model.compile(optimizer=optimizer,
                   loss=tf.losses.MeanSquaredError(),
                   metrics=[tf.metrics.RootMeanSquaredError()])
  
      return model
  </code></pre>
  <p>The Summary of my model:</p>
  
  <pre><code>Model: &quot;model_10&quot;
  __________________________________________________________________________________________________
  Layer (type)                    Output Shape         Param #     Connected to                     
  ==================================================================================================
  attention_mask (InputLayer)     [(None, 300)]        0                                            
  __________________________________________________________________________________________________
  input_ids (InputLayer)          [(None, 300)]        0                                            
  __________________________________________________________________________________________________
  tf_bert_for_sequence_classifica TFSequenceClassifier 109483009   attention_mask[0][0]             
                                                                   input_ids[0][0]                  
  ==================================================================================================
  Total params: 109,483,009
  Trainable params: 109,483,009
  Non-trainable params: 0
  __________________________________________________________________________________________________
  </code></pre>
  <p>The output from my prediction:</p>
  <pre class="lang-py prettyprint-override"><code>data_test = generate_data(df_test.iloc[[1]], labels=False)
  test_pred = model.predict(data_test)
  len(test_pred['logits'])
  </code></pre>
  <pre><code>237
  </code></pre>
  <p><strong>EDIT</strong>: I implement the Dense Layer after the network, but got the same vector of values. How to know the value of the vector in comparison with my final real labeled data.</p>
  <pre class="lang-py prettyprint-override"><code>    output = encoder({'input_ids': input_ids, 'attention_mask': input_attention_mask})[0]
      X = tf.keras.layers.BatchNormalization()(output)
      X = tf.keras.layers.Dense(1, activation='linear')(X)
      
      model = tf.keras.Model(inputs=[input_ids, input_attention_mask], outputs=X)
  </code></pre>
  <p>Some Hints for what I'm doing wrong?</p>