# Error in Lab notebook for Test Validation

**URL:** <https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [December 21, 2023, 4:46pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223 "2023-12-21T16:46:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 4:46pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/1 "2023-12-21T16:46:15Z")

</div>

I am not clear why the test validation is checking for “linear” when the model that is being created is requiring for a binary classification which should be sigmoid. When I use sigmoid the test fails. Need clarification if this is a error in the notebook ?

 ![sigmoid-linear](https://global.discourse-cdn.com/dlai/original/3X/3/2/32514676fdf64db8653930eca74fc2e40e035914.png)

---

<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:** [December 21, 2023, 5:13pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/2 "2023-12-21T17:13:54Z")

</div>

Apparently this question is from Week 2 Assignment 2.

If you look one cell below where you captured your image, you will see that the model is compiled using “from\_logits = True”. When this is combined with using a linear output activation, this gives you a categorical output but uses a more computationally efficient method.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 5:22pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/3 "2023-12-21T17:22:14Z")

</div>

Week 2 - Convolutional Neural Networks - 2nd Assignment on Transfer Learning.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 5:22pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/4 "2023-12-21T17:22:47Z")

</div>

Assignment : [Transfer Learning with MobileNet | Coursera](https://www.coursera.org/learn/convolutional-neural-networks/programming/nZima/transfer-learning-with-mobilenet)

---

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 5:23pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/5 "2023-12-21T17:23:36Z")

</div>

I was able to proceed the rest of the lab with activation function set to “sigmoid”, but this test fails and as a result I could not submit the assignment.

---

<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:** [December 21, 2023, 5:28pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/6 "2023-12-21T17:28:08Z")

</div>

See my previous reply, I have edited it.  
Do not use sigmoid() activation for this exercise.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 5:33pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/7 "2023-12-21T17:33:30Z")

</div>

If we don’t use sigmoid, then how will we satisfy this requirement that is asking for a binary classification in the exercise and that is a requirement for the lab:

# use a prediction layer with one neuron (as a binary classifier only needs one)

```
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(x)

```

---

<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:** [December 21, 2023, 5:33pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/8 "2023-12-21T17:33:42Z")

</div>

Yes, but that is wrong as Tom pointed out. [Here’s a thread](https://community.deeplearning.ai/t/week-3-assignment-compute-total-loss-try-to-set-from-logits-false/243049/2) about why the `from_logits = True` mode is used when we are dealing with either binary or multiclass classifiers with cross entropy loss functions.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 5:34pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/9 "2023-12-21T17:34:11Z")

</div>

Oh ok. thank you for the clarification.

---

<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:** [December 21, 2023, 5:34pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/10 "2023-12-21T17:34:34Z")

</div>

> [@Pradeep\_Nambiar](#):
>
> how will we satisfy this requirement that is asking for a binary classification

Already answered - that’s what “from\_logits = True” does.

---

<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:** [December 21, 2023, 5:35pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/11 "2023-12-21T17:35:37Z")

</div>

It just means that the sigmoid is handled internally in the loss function and gradient calculations. But that also means that when you use the output of the model to make predictions, you need to either manually add the sigmoid to the output or change your criterion to \hat{y} \> 0 means yes.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@Pradeep\_Nambiar](https://community.deeplearning.ai/u/Pradeep_Nambiar)\
**Post date:** [December 21, 2023, 5:40pm UTC](https://community.deeplearning.ai/t/error-in-lab-notebook-for-test-validation/524223/12 "2023-12-21T17:40:17Z")

</div>

Thank you for the clarification. Yes I remember now on this.
