{
  "id": 173229,
  "title": "Is anyone using BCE Label Smoothing with PyTorch?",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/173229",
  "author_name": "",
  "post_date": "2020-08-08T11:51:22.194450600Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>I would be interested in trying BCE Label Smoothing with PyTorch, but I have not yet found an implementation.  If you are doing some sort of Label Smoothing and can share, please do!</p>",
  "messages": [
    {
      "id": "962738",
      "postDate": "08/08/2020 11:51:22",
      "content": "<p>I would be interested in trying BCE Label Smoothing with PyTorch, but I have not yet found an implementation.  If you are doing some sort of Label Smoothing and can share, please do!</p>",
      "rawMarkdown": "I would be interested in trying BCE Label Smoothing with PyTorch, but I have not yet found an implementation.  If you are doing some sort of Label Smoothing and can share, please do!",
      "votes": null
    },
    {
      "id": "962755",
      "postDate": "08/08/2020 12:10:51",
      "content": "<p>I tried with an early model and it did not help.</p>\n<p>you don't need any specific implementation, just use BCELoss with eps and 1 - eps instead of 0 and 1 as targets.</p>",
      "rawMarkdown": "I tried with an early model and it did not help.\n\nyou don't need any specific implementation, just use BCELoss with eps and 1 - eps instead of 0 and 1 as targets.",
      "votes": null
    },
    {
      "id": "962843",
      "postDate": "08/08/2020 13:33:11",
      "content": "<p>I am trying something like this</p>\n\n<p><code>\ndef label_smoothing(preds,targs,smoothing=0.05):\n    targs = torch.where(targs==0,targs,targs-smoothing)\n    return F.binary_cross_entropy_with_logits(preds,targs)\n</code></p>\n\n<p>Not sure if it is actually helping.</p>",
      "rawMarkdown": "I am trying something like this\n\n```\ndef label_smoothing(preds,targs,smoothing=0.05):\n    targs = torch.where(targs==0,targs,targs-smoothing)\n    return F.binary_cross_entropy_with_logits(preds,targs)\n```\n\nNot sure if it is actually helping.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 962755,
      "author_name": "cpmpml",
      "author_url": "",
      "post_date": "08/08/2020 12:10:51",
      "content": "<p>I tried with an early model and it did not help.</p>\n<p>you don't need any specific implementation, just use BCELoss with eps and 1 - eps instead of 0 and 1 as targets.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 962843,
      "author_name": "vishnus",
      "author_url": "",
      "post_date": "08/08/2020 13:33:11",
      "content": "<p>I am trying something like this</p>\n\n<p><code>\ndef label_smoothing(preds,targs,smoothing=0.05):\n    targs = torch.where(targs==0,targs,targs-smoothing)\n    return F.binary_cross_entropy_with_logits(preds,targs)\n</code></p>\n\n<p>Not sure if it is actually helping.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "962738": "I would be interested in trying BCE Label Smoothing with PyTorch, but I have not yet found an implementation.  If you are doing some sort of Label Smoothing and can share, please do!",
    "962755": "I tried with an early model and it did not help.\n\nyou don't need any specific implementation, just use BCELoss with eps and 1 - eps instead of 0 and 1 as targets.",
    "962843": "I am trying something like this\n\n```\ndef label_smoothing(preds,targs,smoothing=0.05):\n    targs = torch.where(targs==0,targs,targs-smoothing)\n    return F.binary_cross_entropy_with_logits(preds,targs)\n```\n\nNot sure if it is actually helping."
  },
  "source": "meta"
}