# Week 2 Assignment 2 alpaca\_model new

**URL:** <https://community.deeplearning.ai/t/week-2-assignment-2-alpaca-model-new/135340>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [June 6, 2022, 8:57pm UTC](https://community.deeplearning.ai/t/week-2-assignment-2-alpaca-model-new/135340 "2022-06-06T20:57:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abelian\_group\_chen](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@abelian\_group\_chen](https://community.deeplearning.ai/u/abelian_group_chen)\
**Post date:** [June 6, 2022, 8:57pm UTC](https://community.deeplearning.ai/t/week-2-assignment-2-alpaca-model-new/135340/1 "2022-06-06T20:57:50Z")

</div>

Since we are adding a binary classification layer, why is the test case checking for a linear dense layer as the output? Shouldn’t it be a sigmoid dense layer?

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [June 6, 2022, 11:46pm UTC](https://community.deeplearning.ai/t/week-2-assignment-2-alpaca-model-new/135340/2 "2022-06-06T23:46:38Z")

</div>

There are two ways to get a classifier output.

1. Use sigmoid activation in the output layer
2. Use a linear activation in the output layer, and tell the prediction function to convert the linear output to logits.

Both methods give the same results, but the 2nd method has some mathematical advantages under TensorFlow.

---

<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:** [June 6, 2022, 11:50pm UTC](https://community.deeplearning.ai/t/week-2-assignment-2-alpaca-model-new/135340/3 "2022-06-06T23:50:03Z")

</div>

Yes, once we switched to using TF, we use method 2) that Tom describes: we always define the output layer without the activation function and then take advantage of the _from\_logits = True_ mode of the loss functions to integrate the output activation and loss calculations together. It’s been that way since we saw TF for the very first time in Course 2 Week 3.

---

<div class="post-metadata">

**Author:** ![abelian\_group\_chen](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@abelian\_group\_chen](https://community.deeplearning.ai/u/abelian_group_chen)\
**Post date:** [June 7, 2022, 1:13am UTC](https://community.deeplearning.ai/t/week-2-assignment-2-alpaca-model-new/135340/4 "2022-06-07T01:13:47Z")

</div>

Thanks Tom and Paul for the answers!
