# First binary classification model

**URL:** <https://community.deeplearning.ai/t/first-binary-classification-model/159796>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [July 12, 2022, 12:43pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796 "2022-07-12T12:43:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![IZZETTIN\_ALHALIL](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@IZZETTIN\_ALHALIL](https://community.deeplearning.ai/u/IZZETTIN_ALHALIL)\
**Post date:** [July 12, 2022, 12:43pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796/1 "2022-07-12T12:43:44Z")

</div>

Why we did set 0.5 as threshold to classify that is cat or non-cat  
and if i have more than one class, how can I set the thresholds

thanks in advance

---

<div class="post-metadata">

**Author:** ![anon57530071](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@anon57530071](https://community.deeplearning.ai/u/anon57530071)\
**Post date:** [July 12, 2022, 1:02pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796/2 "2022-07-12T13:02:35Z")

</div>

There are two types of classifications, i.e, Binary classification and Multi-class classification. In the case of binary classification, we can only support true or false, like cat or non-cat. But, output from a neural network may have broader values like -1000, 30, 4000, etc. So, as you see in your assignment, Sigmoid function is applied. Sigmoid is very useful function to convert output from a neural network into the value between 0 and 1. So, we can just specify 0.5 as a threshold.

![image](https://global.discourse-cdn.com/dlai/original/3X/c/1/c17def4cbb9fb9970e179a1ea526793063f2c9d1.png)

If we have multiple classes, i.e, multi-class classification, we usually prepare multiple neurons as an output layer. Each correspond to output class, like “cat”, “dog”, etc. Then, we usually apply Softmax function to summarize likelihood of each class.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![IZZETTIN\_ALHALIL](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@IZZETTIN\_ALHALIL](https://community.deeplearning.ai/u/IZZETTIN_ALHALIL)\
**Post date:** [July 12, 2022, 1:27pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796/3 "2022-07-12T13:27:40Z")

</div>

thanks very much for your reply  
alright, if my output values have no threshold, so the model will not be classification,  
in this case which activation function should I use for the output layer as well as within the hidden layer?

---

<div class="post-metadata">

**Author:** ![anon57530071](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@anon57530071](https://community.deeplearning.ai/u/anon57530071)\
**Post date:** [July 12, 2022, 2:24pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796/4 "2022-07-12T14:24:14Z")

</div>

There are different types of deep learning tasks. Typical ones are, binary classification, multi-class classification, logistic regression, clustering, and so on. You know that deep learning is used for machine translation, image classification, object detection, etc, as applications. We need to select appropriate activation functions for those.

It may be slightly difficult to say that which activation function should be used for what, but each has different characteristics. So, there are some recommended ways to use particular activation functions.

In the case of classifications, Softmax is mostly used for multi-class classification and sigmoid for binary classification for the output layer as we discussed.  
For for hidden networks, we need to consider what is the characteristics of input data, how we can enhance linear functions (like Dense) with adding non-linear activation, and also how we can keep “gradients” for backpropagation that you will learn in the later lecture. Sigmoid is typically not used in a hidden layer, since its gradient is small, which potentially results in “vanishing gradient” that is the big problem for optimizing a network. Tanh has more gradients than Sigmoid. So, it may be used in some cases. ReLU is one of popular activation functions, since its nature. ReLU cuts off minus data, and picks up plus-data as is. So, it is easy to get stable derivatives, which is very good for backpropagation. In this sense, ReLU is mostly used in a hidden layer. Due to its simpleness, it is not used for the output layer mostly. If minus values have important meanings, and output from neurons should keep those, then, we can not use ReLU since it cuts off minus value.

There are lots of activation functions like [this](https://www.tensorflow.org/api_docs/python/tf/keras/activations). You do not need to go in detail, but will learn some key activation functions in the series of assignments in this specialization.

This is just an introduction, but hope this helps some.

---

<div class="post-metadata">

**Author:** ![IZZETTIN\_ALHALIL](https://avatars.discourse-cdn.com/v4/letter/i/2acd7d/32.png) [@IZZETTIN\_ALHALIL](https://community.deeplearning.ai/u/IZZETTIN_ALHALIL)\
**Post date:** [July 12, 2022, 2:32pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796/5 "2022-07-12T14:32:27Z")

</div>

thanks for your clarification  
it is highly appreciated 🌹

---

<div class="post-metadata">

**Author:** ![Kic](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/kic/32/76339_2.png) [@Kic](https://community.deeplearning.ai/u/Kic)\
**Post date:** [July 12, 2022, 2:46pm UTC](https://community.deeplearning.ai/t/first-binary-classification-model/159796/6 "2022-07-12T14:46:04Z")

</div>

@anon57530071 has given a very good and broad coverage on activation functions. Just would like to add an extra point here, reLu’s formula f(x) = max(0,x) is simple and less computational demanding, comparing to sigmoid and tanh.
