# Exercise 2 - alpaca\_model (linear)

**URL:** <https://community.deeplearning.ai/t/exercise-2-alpaca-model-linear/419260>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [August 16, 2023, 11:41am UTC](https://community.deeplearning.ai/t/exercise-2-alpaca-model-linear/419260 "2023-08-16T11:41:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omar\_Alwaily](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@Omar\_Alwaily](https://community.deeplearning.ai/u/Omar_Alwaily)\
**Post date:** [August 16, 2023, 11:41am UTC](https://community.deeplearning.ai/t/exercise-2-alpaca-model-linear/419260/1 "2023-08-16T11:41:45Z")

</div>

In Programming Assignment: Transfer Learning with MobileNet at Exercise 2 - alpaca\_model  
when I use sigmoid as activation function does not pass test when I use linear as activation function it is pass why?  
I think in binary classification should use sigmoid.

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 16, 2023, 12:04pm UTC](https://community.deeplearning.ai/t/exercise-2-alpaca-model-linear/419260/2 "2023-08-16T12:04:47Z")

</div>

Please pay attention to the logits flag in the loss function:

```auto
loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),

```

When logits is `True`, softmax is not required as the output activation function. See [this](https://community.deeplearning.ai/t/not-able-to-understand-why-getting-error/109768/10) as well.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [August 16, 2023, 7:53pm UTC](https://community.deeplearning.ai/t/exercise-2-alpaca-model-linear/419260/3 "2023-08-16T19:53:21Z")

</div>

Right: the point is that the `sigmoid` (or `softmax`) _is_ included, but it’s being handled internally by the loss function instead of explicitly in your code. [Here’s a thread](https://community.deeplearning.ai/t/week-3-assignment-compute-total-loss-try-to-set-from-logits-false/243049/2) which explains why they do it that way.
