# C1W2 - Lecture Video - Contrastive Loss - Explanation Not Clear

**URL:** <https://dlai.staged-by-discourse.com/t/c1w2-lecture-video-contrastive-loss-explanation-not-clear/811912>\
**Category:** Custom Models, Layers and Loss Functions with TF\
**Tags:** week-module-2\
**Created:** [May 8, 2025, 12:07am UTC](https://dlai.staged-by-discourse.com/t/c1w2-lecture-video-contrastive-loss-explanation-not-clear/811912 "2025-05-08T00:07:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wendy](https://sea1.discourse-cdn.com/dlaistaging/user_avatar/dlai.staged-by-discourse.com/wendy/32/8167_2.png) [@Wendy](https://dlai.staged-by-discourse.com/u/Wendy)\
**Post date:** [May 15, 2025, 11:29pm UTC](https://dlai.staged-by-discourse.com/t/c1w2-lecture-video-contrastive-loss-explanation-not-clear/811912/2 "2025-05-15T23:29:37Z")

</div>

Hi @classical_leap,  
I can see your point that that part of the explanation could be confusing. To me, the important aspects of the contrastive loss formula is that:  
1). One part of the formula (the D squared part) is for the case where Y=1, and the other (the max(margin-D,0) squared part) is for Y=0, where Y=1 means that we expect the two images to be similar, and Y=0 means we expect the images to be different  
2). Our loss should be large if the distance, D, between the two images is far when we expected the images to be similar, and the loss should also be large if we expected the images to dis-similar, but the distance, D, between the two was small.

There’s a little more explanation of this in this old post: [C1W2 -\> understand the constrastive loss function](http://dlai.staged-by-discourse.com/t/c1w2-understand-the-constrastive-loss-function/203182)

---

_[View the full topic](https://dlai.staged-by-discourse.com/t/c1w2-lecture-video-contrastive-loss-explanation-not-clear/811912)._
