# Computing total loss in assignment

**URL:** <https://dlai.staged-by-discourse.com/t/computing-total-loss-in-assignment/289945>\
**Category:** Improving Deep Neural Networks: Hyperparameter tun\
**Tags:** coursera-platform\
**Created:** [March 13, 2023, 11:39pm UTC](https://dlai.staged-by-discourse.com/t/computing-total-loss-in-assignment/289945 "2023-03-13T23:39:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatemeh-Esmaeili](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@Fatemeh-Esmaeili](https://dlai.staged-by-discourse.com/u/Fatemeh-Esmaeili)\
**Post date:** [March 13, 2023, 11:39pm UTC](https://dlai.staged-by-discourse.com/t/computing-total-loss-in-assignment/289945/1 "2023-03-13T23:39:17Z")

</div>

Hi

I am pretty new to TensorFlow, and I would like to know how I can correctly implement the total loss by TensorFlow with the help of cross-entropy and reduce\_sum.

I used the guidance in the notebook, and the result of my code was slightly different from the expected value.

I mean, my output is tf.Tensor(0.88275003, shape=(), dtype=float32) while the expected value is  
tf.Tensor(0.810287, shape=(), dtype=float32). And running the test section, I receive this output “Test does not match. Did you get the reduce sum of your loss functions?”

Could you please help me to debug my code and realize my mistake?

Many thanks

---

<div class="post-metadata">

**Author:** ![rmwkwok](https://sea1.discourse-cdn.com/dlaistaging/user_avatar/dlai.staged-by-discourse.com/rmwkwok/32/126977_2.png) [@rmwkwok](https://dlai.staged-by-discourse.com/u/rmwkwok)\
**Post date:** [March 14, 2023, 2:40am UTC](https://dlai.staged-by-discourse.com/t/computing-total-loss-in-assignment/289945/2 "2023-03-14T02:40:48Z")

</div>

Hello @Fatemeh-Esmaeili,

[This thread](http://dlai.staged-by-discourse.com/t/dls-course2-week-3-exercise-6-compute-total-loss-method/234856) may be helpful to your situation.

Cheers,  
Raymond
