# Transform VisualBERT prediction\_logits to probabilities

**URL:** <https://discuss.huggingface.co/t/transform-visualbert-prediction-logits-to-probabilities/46998>\
**Category:** Beginners\
**Created:** [July 16, 2023, 3:11pm UTC](https://discuss.huggingface.co/t/transform-visualbert-prediction-logits-to-probabilities/46998 "2023-07-16T15:11:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgalfre](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@mgalfre](https://discuss.huggingface.co/u/mgalfre)\
**Post date:** [July 16, 2023, 3:11pm UTC](https://discuss.huggingface.co/t/transform-visualbert-prediction-logits-to-probabilities/46998/1 "2023-07-16T15:11:32Z")

</div>

Hello,  
I finetuned a VisualBertForPreTraining model in order to perform a binary classification task using the Hateful Memes Dataset. However, my issue is that among the model’s outputs, obtained in the following way:

```auto
outputs = model(
    input_ids=input_ids, 
    attention_mask=attention_mask, 
    token_type_ids=token_type_ids, 
    visual_embeds=visual_embeds, 
    visual_attention_mask=visual_attention_mask, 
    visual_token_type_ids=visual_token_type_ids,
    labels=token_labels
)

```

there are no probabilities for the classification. Therefore, I believe it’s necessary to construct a classification head for the prediction\_logits present in the model’s output.  
Specifically, what I obtain as `output.prediction_logits` during the evaluation phase, for a batch of 16 inputs, is a tensor of size `torch.Size([16, 150, 30522])`.  
How can I transform this tensor into probabilities?

Thank you very much in advance for your help.
