# Week3\_\_\_Tensorflow Introduction\_\_Compute cost

**URL:** <https://community.deeplearning.ai/t/week3-tensorflow-introduction-compute-cost/13556>\
**Category:** Improving Deep Neural Networks: Hyperparameter tun\
**Tags:** coursera-platform\
**Created:** [June 12, 2021, 2:45am UTC](https://community.deeplearning.ai/t/week3-tensorflow-introduction-compute-cost/13556 "2021-06-12T02:45:53Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![kampamocha](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/kampamocha/32/234_2.png) [@kampamocha](https://community.deeplearning.ai/u/kampamocha)\
**Post date:** [August 17, 2021, 3:24pm UTC](https://community.deeplearning.ai/t/week3-tensorflow-introduction-compute-cost/13556/14 "2021-08-17T15:24:18Z")

</div>

Hi @Hussam,

You are right, we should use `categorical_cross_entropy`. At the time of my previous comment the notebook specified that you should use `binary_cross_entropy`, later that was revised and changed to what it is now, which makes more sense.

If you are interested, you can check some discussions about it:

> [@(Tensorflow assignment )Why not compute A3 in forward\_prop function?](https://community.deeplearning.ai/t/tensorflow-assignment-why-not-compute-a3-in-forward-prop-function/1658/2):
>
> That’s because they want you to use the Binary\_crossentropy loss function with the from\_logits = True argument, which causes the sigmoid calculation to be incorporated in the loss computation. That is preferred because they can manage numerical stability better when they do the two together. E.g. dealing with problems with “saturated” sigmoid output values. [Here’s the doc page for Binary\_crossentropy](https://www.tensorflow.org/api_docs/python/tf/keras/losses/binary_crossentropy). They don’t really explain what the from\_logits = True argument does in the assignment, but the…

> [@Cannot compute\_cost course 2 week 3](https://community.deeplearning.ai/t/cannot-compute-cost-course-2-week-3/3117/6):
>
> Update: Please note that after this thread was created, the Course Staff made some significant updates to this assignment, which include switching to using CategoricalCrossEntropy for the loss function in this section. Because we specify the from\_logits = True argument, that means that the loss logic will apply either sigmoid or softmax to the logits to compute the actual \hat{y} values and then will compute the cross entropy loss between the predictions and the labels: -y\_true \* log(sigmoid(y…

---

_[View the full topic](https://community.deeplearning.ai/t/week3-tensorflow-introduction-compute-cost/13556)._
