Skip to content

Commit 7f70854

Browse files
committed
[docs] fix contrastive loss eq
make documented equation match the correct implementation of the `max(margin - d, 0)^2` term in the loss. see BVLC#2321
1 parent e4aed04 commit 7f70854

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/caffe/loss_layers.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ class LossLayer : public Layer<Dtype> {
128128
/**
129129
* @brief Computes the contrastive loss @f$
130130
* E = \frac{1}{2N} \sum\limits_{n=1}^N \left(y\right) d +
131-
* \left(1-y\right) \max \left(margin-d, 0\right)
131+
* \left(1-y\right) \max \left(margin-d, 0\right)^2
132132
* @f$ where @f$
133-
* d = \left| \left| a_n - b_n \right| \right|_2^2 @f$. This can be
133+
* d = \left| \left| a_n - b_n \right| \right|_2 @f$. This can be
134134
* used to train siamese networks.
135135
*
136136
* @param bottom input Blob vector (length 3)
@@ -144,9 +144,9 @@ class LossLayer : public Layer<Dtype> {
144144
* -# @f$ (1 \times 1 \times 1 \times 1) @f$
145145
* the computed contrastive loss: @f$ E =
146146
* \frac{1}{2N} \sum\limits_{n=1}^N \left(y\right) d +
147-
* \left(1-y\right) \max \left(margin-d, 0\right)
147+
* \left(1-y\right) \max \left(margin-d, 0\right)^2
148148
* @f$ where @f$
149-
* d = \left| \left| a_n - b_n \right| \right|_2^2 @f$.
149+
* d = \left| \left| a_n - b_n \right| \right|_2 @f$.
150150
* This can be used to train siamese networks.
151151
*/
152152
template <typename Dtype>

0 commit comments

Comments
 (0)