{"action":"created","issue":{"url":"https://api.github.com/repos/BVLC/caffe/issues/3310","labels_url":"https://api.github.com/repos/BVLC/caffe/issues/3310/labels{/name}","comments_url":"https://api.github.com/repos/BVLC/caffe/issues/3310/comments","events_url":"https://api.github.com/repos/BVLC/caffe/issues/3310/events","html_url":"https://github.com/BVLC/caffe/pull/3310","id":115961231,"number":3310,"title":"DOC: Fix consistent typo in contrastive loss","user":{"login":"gustavla","id":902935,"avatar_url":"https://avatars.githubusercontent.com/u/902935?v=3","gravatar_id":"","url":"https://api.github.com/users/gustavla","html_url":"https://github.com/gustavla","followers_url":"https://api.github.com/users/gustavla/followers","following_url":"https://api.github.com/users/gustavla/following{/other_user}","gists_url":"https://api.github.com/users/gustavla/gists{/gist_id}","starred_url":"https://api.github.com/users/gustavla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gustavla/subscriptions","organizations_url":"https://api.github.com/users/gustavla/orgs","repos_url":"https://api.github.com/users/gustavla/repos","events_url":"https://api.github.com/users/gustavla/events{/privacy}","received_events_url":"https://api.github.com/users/gustavla/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BVLC/caffe/labels/documentation","name":"documentation","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-09T20:41:43Z","updated_at":"2015-11-10T05:48:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/BVLC/caffe/pulls/3310","html_url":"https://github.com/BVLC/caffe/pull/3310","diff_url":"https://github.com/BVLC/caffe/pull/3310.diff","patch_url":"https://github.com/BVLC/caffe/pull/3310.patch"},"body":"If a pair is similar, the contrastive loss should take the squared distance and not the distance. This is clearly what the code is doing, but the documentation gets it consistently wrong.\r\n\r\nThis is straight from the code with an arrow added:\r\n\r\n```cpp\r\nif (static_cast<int>(bottom[2]->cpu_data()[i])) {  // similar pairs\r\n  loss += dist_sq_.cpu_data()[i];  // <---- clearly d^2 and not d\r\n} else {  // dissimilar pairs\r\n  if (legacy_version) {\r\n    loss += std::max(margin - dist_sq_.cpu_data()[i], Dtype(0.0));\r\n  } else {\r\n    Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), 0.0);\r\n    loss += dist*dist;\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/BVLC/caffe/issues/comments/155301434","html_url":"https://github.com/BVLC/caffe/pull/3310#issuecomment-155301434","issue_url":"https://api.github.com/repos/BVLC/caffe/issues/3310","id":155301434,"user":{"login":"seanbell","id":1844189,"avatar_url":"https://avatars.githubusercontent.com/u/1844189?v=3","gravatar_id":"","url":"https://api.github.com/users/seanbell","html_url":"https://github.com/seanbell","followers_url":"https://api.github.com/users/seanbell/followers","following_url":"https://api.github.com/users/seanbell/following{/other_user}","gists_url":"https://api.github.com/users/seanbell/gists{/gist_id}","starred_url":"https://api.github.com/users/seanbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanbell/subscriptions","organizations_url":"https://api.github.com/users/seanbell/orgs","repos_url":"https://api.github.com/users/seanbell/repos","events_url":"https://api.github.com/users/seanbell/events{/privacy}","received_events_url":"https://api.github.com/users/seanbell/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T05:48:14Z","updated_at":"2015-11-10T05:48:14Z","body":"LGTM"}}