{
  "id": 311007,
  "title": "Why easy_margin?",
  "url": "/competitions/happy-whale-and-dolphin/discussion/311007",
  "author_name": "",
  "post_date": "2022-03-04T10:07:19.941248300Z",
  "votes": 5,
  "comment_count": 5,
  "views": 0,
  "content": "<p>I saw that a lot of people are using arcface, so I read the paper but find that the code from this link (<a href=\"url\" target=\"_blank\">https://www.kaggle.com/aikhmelnytskyy/happywhale-effnet-b7-fork-with-detic-crop-3b3093</a>) has a variable named as <strong>easy_margin</strong> (Please see the part subtitled as <strong><em>Model</em></strong>, the class named as <strong><em>ArcMarginProduct</em></strong>), which is different from the algorithm presented in the paper. <br>\n<strong>So why the code uses easy_margin?</strong> <br>\nThank you, if you can help to explain it🤝👍.</p>",
  "messages": [
    {
      "id": "1711795",
      "postDate": "03/04/2022 10:07:19",
      "content": "<p>I saw that a lot of people are using arcface, so I read the paper but find that the code from this link (<a href=\"url\" target=\"_blank\">https://www.kaggle.com/aikhmelnytskyy/happywhale-effnet-b7-fork-with-detic-crop-3b3093</a>) has a variable named as <strong>easy_margin</strong> (Please see the part subtitled as <strong><em>Model</em></strong>, the class named as <strong><em>ArcMarginProduct</em></strong>), which is different from the algorithm presented in the paper. <br>\n<strong>So why the code uses easy_margin?</strong> <br>\nThank you, if you can help to explain it🤝👍.</p>",
      "rawMarkdown": "I saw that a lot of people are using arcface, so I read the paper but find that the code from this link ([https://www.kaggle.com/aikhmelnytskyy/happywhale-effnet-b7-fork-with-detic-crop-3b3093](url)) has a variable named as **easy_margin** (Please see the part subtitled as ***Model***, the class named as ***ArcMarginProduct***), which is different from the algorithm presented in the paper. \n**So why the code uses easy_margin?** \nThank you, if you can help to explain it🤝👍.",
      "votes": null
    },
    {
      "id": "1712243",
      "postDate": "03/04/2022 17:56:59",
      "content": "<p>If the easy margin is true, as long as the included angle is less than 90 degrees, an m is added to the angle. If it is false, take self.th as the threshold. You can draw the following picture. If the angle value theta is less than m, the cosine value must be greater than the threshold in the monotonic interval 0-pi. So the role of th is to ensure that theta plus m are still in the monotonic range 0-pi.</p>",
      "rawMarkdown": "If the easy margin is true, as long as the included angle is less than 90 degrees, an m is added to the angle. If it is false, take self.th as the threshold. You can draw the following picture. If the angle value theta is less than m, the cosine value must be greater than the threshold in the monotonic interval 0-pi. So the role of th is to ensure that theta plus m are still in the monotonic range 0-pi.",
      "votes": null
    },
    {
      "id": "1712348",
      "postDate": "03/04/2022 21:14:02",
      "content": "<p>the arcface problem is strange behavior around 180 degrees (loss in 180 will be lower than in 170), so easy margin is two ways to fix it, see image:<br>\n<img src=\"https://habrastorage.org/r/w1560/webt/ne/te/7e/nete7es63eurgjqii9lgcklxmr8.png\" alt=\"image \"></p>",
      "rawMarkdown": "the arcface problem is strange behavior around 180 degrees (loss in 180 will be lower than in 170), so easy margin is two ways to fix it, see image:\n![image ](https://habrastorage.org/r/w1560/webt/ne/te/7e/nete7es63eurgjqii9lgcklxmr8.png)",
      "votes": null
    },
    {
      "id": "1712534",
      "postDate": "03/05/2022 03:05:53",
      "content": "<p>Thanks! So the purpose of the two options (easy_margin or not) is to make sure the gradient of theta over the function always has the same sign, and the two options are just two ways to do this. Is that right?🙏</p>",
      "rawMarkdown": "Thanks! So the purpose of the two options (easy_margin or not) is to make sure the gradient of theta over the function always has the same sign, and the two options are just two ways to do this. Is that right?🙏",
      "votes": null
    },
    {
      "id": "1712541",
      "postDate": "03/05/2022 03:14:06",
      "content": "<p>Thanks for the picture!</p>",
      "rawMarkdown": "Thanks for the picture!",
      "votes": null
    },
    {
      "id": "1712769",
      "postDate": "03/05/2022 10:03:03",
      "content": "<p>thx for the info.</p>",
      "rawMarkdown": "thx for the info.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1712243,
      "author_name": "vladvdv",
      "author_url": "",
      "post_date": "03/04/2022 17:56:59",
      "content": "<p>If the easy margin is true, as long as the included angle is less than 90 degrees, an m is added to the angle. If it is false, take self.th as the threshold. You can draw the following picture. If the angle value theta is less than m, the cosine value must be greater than the threshold in the monotonic interval 0-pi. So the role of th is to ensure that theta plus m are still in the monotonic range 0-pi.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1712534,
          "author_name": "trunwayqu",
          "author_url": "",
          "post_date": "03/05/2022 03:05:53",
          "content": "<p>Thanks! So the purpose of the two options (easy_margin or not) is to make sure the gradient of theta over the function always has the same sign, and the two options are just two ways to do this. Is that right?🙏</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1712348,
      "author_name": "kwentar",
      "author_url": "",
      "post_date": "03/04/2022 21:14:02",
      "content": "<p>the arcface problem is strange behavior around 180 degrees (loss in 180 will be lower than in 170), so easy margin is two ways to fix it, see image:<br>\n<img src=\"https://habrastorage.org/r/w1560/webt/ne/te/7e/nete7es63eurgjqii9lgcklxmr8.png\" alt=\"image \"></p>",
      "votes": null,
      "replies": [
        {
          "id": 1712541,
          "author_name": "trunwayqu",
          "author_url": "",
          "post_date": "03/05/2022 03:14:06",
          "content": "<p>Thanks for the picture!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1712769,
          "author_name": "dragonzhang",
          "author_url": "",
          "post_date": "03/05/2022 10:03:03",
          "content": "<p>thx for the info.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1711795": "I saw that a lot of people are using arcface, so I read the paper but find that the code from this link ([https://www.kaggle.com/aikhmelnytskyy/happywhale-effnet-b7-fork-with-detic-crop-3b3093](url)) has a variable named as **easy_margin** (Please see the part subtitled as ***Model***, the class named as ***ArcMarginProduct***), which is different from the algorithm presented in the paper. \n**So why the code uses easy_margin?** \nThank you, if you can help to explain it🤝👍.",
    "1712243": "If the easy margin is true, as long as the included angle is less than 90 degrees, an m is added to the angle. If it is false, take self.th as the threshold. You can draw the following picture. If the angle value theta is less than m, the cosine value must be greater than the threshold in the monotonic interval 0-pi. So the role of th is to ensure that theta plus m are still in the monotonic range 0-pi.",
    "1712348": "the arcface problem is strange behavior around 180 degrees (loss in 180 will be lower than in 170), so easy margin is two ways to fix it, see image:\n![image ](https://habrastorage.org/r/w1560/webt/ne/te/7e/nete7es63eurgjqii9lgcklxmr8.png)",
    "1712534": "Thanks! So the purpose of the two options (easy_margin or not) is to make sure the gradient of theta over the function always has the same sign, and the two options are just two ways to do this. Is that right?🙏",
    "1712541": "Thanks for the picture!",
    "1712769": "thx for the info."
  },
  "source": "meta"
}