# Huggingface transformers classification using num\_labels 1 vs 2

**URL:** <https://discuss.huggingface.co/t/huggingface-transformers-classification-using-num-labels-1-vs-2/16539>\
**Category:** 🤗Transformers\
**Created:** [April 6, 2022, 2:01pm UTC](https://discuss.huggingface.co/t/huggingface-transformers-classification-using-num-labels-1-vs-2/16539 "2022-04-06T14:01:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitempe](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@nitempe](https://discuss.huggingface.co/u/nitempe)\
**Post date:** [April 6, 2022, 2:01pm UTC](https://discuss.huggingface.co/t/huggingface-transformers-classification-using-num-labels-1-vs-2/16539/1 "2022-04-06T14:01:52Z")

</div>

question 1)

For a binary classification problem I could use `num_labels` as 1 (positive or not) or 2 (positive and negative). Is there any guideline regarding which setting is better? It seems that if we use 1 then probability would be calculated using `sigmoid` function and if we use 2 then probabilities would be calculated using `softmax` function.

question 2)  
In both cases are my y labels going to be same? each data point will have 0 or 1 and not one hot encoding? For example, if I have 2 data points then y would be `0,1` and not `[0,0],[0,1]`

I have very unbalanced classification problem where class 1 is present only 2% of times. In my training data I am oversampling

---

<div class="post-metadata">

**Author:** ![bryanzhou008](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bryanzhou008/32/5463_2.png) [@bryanzhou008](https://discuss.huggingface.co/u/bryanzhou008)\
**Post date:** [August 19, 2022, 5:02pm UTC](https://discuss.huggingface.co/t/huggingface-transformers-classification-using-num-labels-1-vs-2/16539/2 "2022-08-19T17:02:40Z")

</div>

For Question 1 I am wondering the same thing. Although the docs all use num\_labels=2 for binary classification, I am currently using num\_labels=1. Hope to know if there are any differences.
