{
  "id": 76012,
  "title": " Why does not Triplet loss(ReID) approach work?",
  "url": "/competitions/humpback-whale-identification/discussion/76012",
  "author_name": "hirune924",
  "post_date": "2018-12-28T14:10:22.229000",
  "votes": 8,
  "comment_count": 8,
  "views": 0,
  "content": "<p>I think that Triplet loss(ReID) is a more effective approach than Classification in this problem.\n<a href=\"https://github.com/omoindrot/tensorflow-triplet-loss\">https://github.com/omoindrot/tensorflow-triplet-loss</a>\n<a href=\"https://arxiv.org/abs/1503.03832\">https://arxiv.org/abs/1503.03832</a>\n<a href=\"http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w6/Liao_Triplet-Based_Deep_Similarity_ICCV_2017_paper.pdf\">http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w6/Liao_Triplet-Based_Deep_Similarity_ICCV_2017_paper.pdf</a></p>\n\n<p>However、that approach does not seem to work well as shown below\n<a href=\"https://www.kaggle.com/ateplyuk/keras-triplet-loss-lb-0-224\">https://www.kaggle.com/ateplyuk/keras-triplet-loss-lb-0-224</a>\n<a href=\"https://www.kaggle.com/ashishpatel26/triplet-loss-network-for-humpback-whale-prediction\">https://www.kaggle.com/ashishpatel26/triplet-loss-network-for-humpback-whale-prediction</a></p>\n\n<p>Even in my local, this approach quickly becomes over fitting. Is there anyone who tried a similar approach?</p>",
  "messages": [
    {
      "id": 446687,
      "postDate": "2018-12-28T14:10:22.230Z",
      "content": "<p>I think that Triplet loss(ReID) is a more effective approach than Classification in this problem.\n<a href=\"https://github.com/omoindrot/tensorflow-triplet-loss\">https://github.com/omoindrot/tensorflow-triplet-loss</a>\n<a href=\"https://arxiv.org/abs/1503.03832\">https://arxiv.org/abs/1503.03832</a>\n<a href=\"http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w6/Liao_Triplet-Based_Deep_Similarity_ICCV_2017_paper.pdf\">http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w6/Liao_Triplet-Based_Deep_Similarity_ICCV_2017_paper.pdf</a></p>\n\n<p>However、that approach does not seem to work well as shown below\n<a href=\"https://www.kaggle.com/ateplyuk/keras-triplet-loss-lb-0-224\">https://www.kaggle.com/ateplyuk/keras-triplet-loss-lb-0-224</a>\n<a href=\"https://www.kaggle.com/ashishpatel26/triplet-loss-network-for-humpback-whale-prediction\">https://www.kaggle.com/ashishpatel26/triplet-loss-network-for-humpback-whale-prediction</a></p>\n\n<p>Even in my local, this approach quickly becomes over fitting. Is there anyone who tried a similar approach?</p>",
      "rawMarkdown": "I think that Triplet loss(ReID) is a more effective approach than Classification in this problem.\nhttps://github.com/omoindrot/tensorflow-triplet-loss\nhttps://arxiv.org/abs/1503.03832\nhttp://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w6/Liao_Triplet-Based_Deep_Similarity_ICCV_2017_paper.pdf\n\nHowever、that approach does not seem to work well as shown below\nhttps://www.kaggle.com/ateplyuk/keras-triplet-loss-lb-0-224\nhttps://www.kaggle.com/ashishpatel26/triplet-loss-network-for-humpback-whale-prediction\n\nEven in my local, this approach quickly becomes over fitting. Is there anyone who tried a similar approach?",
      "votes": 7
    },
    {
      "id": 449762,
      "postDate": "2019-01-03T17:46:57.183Z",
      "content": "<p>I am investigating a triplet loss approach as well. The challenges I face currently is how to treat the 'new_whale' observations with this approach. I started to treat them just as negative examples but this looks limiting.</p>",
      "rawMarkdown": "I am investigating a triplet loss approach as well. The challenges I face currently is how to treat the 'new_whale' observations with this approach. I started to treat them just as negative examples but this looks limiting."
    },
    {
      "id": 449281,
      "postDate": "2019-01-02T22:32:35.383Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 448936,
      "postDate": "2019-01-02T11:38:57.013Z",
      "content": "<p>The triplet loss approach is pretty promising in our experiments (LB 0.78). The trick (for us) was to use the triplet loss in tensorflow.contrib. <a href=\"https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py\">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py</a></p>",
      "rawMarkdown": "The triplet loss approach is pretty promising in our experiments (LB 0.78). The trick (for us) was to use the triplet loss in tensorflow.contrib. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py",
      "votes": 4,
      "isDeleted": true,
      "replies": [
        {
          "id": 449132,
          "postDate": "2019-01-02T17:44:43.610Z",
          "content": "<p>Thank you for your advice!!\nIn my trials, I used loss function in PyTorch. But it does not include semi hard negative mining trick. I think that it may be very important. I'm going to give it a try!! Thank you!!\n<a href=\"https://pytorch.org/docs/stable/nn.html#torch.nn.TripletMarginLoss\">https://pytorch.org/docs/stable/nn.html#torch.nn.TripletMarginLoss</a></p>",
          "rawMarkdown": "Thank you for your advice!!\nIn my trials, I used loss function in PyTorch. But it does not include semi hard negative mining trick. I think that it may be very important. I'm going to give it a try!! Thank you!!\nhttps://pytorch.org/docs/stable/nn.html#torch.nn.TripletMarginLoss",
          "votes": 1
        },
        {
          "id": 449275,
          "postDate": "2019-01-02T22:24:27.240Z",
          "content": "<p>I'm new to metric learning, and I'd like to adopt it as my approach. What is the difference between \"Triplet Loss\" and \"Triplet Semi-Hard Loss\"? I get the basic idea of Triplet Loss, in that we are trying to push negative examples further away from positive examples by a small margin (like a SVM). So, if I am understanding this correctly, a semi-hard triplet loss is using a semi-hard negative instead of a hard negative for training? Semi-hard being a negative that is not closer to the anchor compared to the positive, but still has a non-zero loss? Thanks, @Gert-Jan and <a href=\"/hirune924\">@hirune924</a>.</p>",
          "rawMarkdown": "I'm new to metric learning, and I'd like to adopt it as my approach. What is the difference between \"Triplet Loss\" and \"Triplet Semi-Hard Loss\"? I get the basic idea of Triplet Loss, in that we are trying to push negative examples further away from positive examples by a small margin (like a SVM). So, if I am understanding this correctly, a semi-hard triplet loss is using a semi-hard negative instead of a hard negative for training? Semi-hard being a negative that is not closer to the anchor compared to the positive, but still has a non-zero loss? Thanks, @Gert-Jan and @hirune924."
        },
        {
          "id": 449282,
          "postDate": "2019-01-02T22:33:14.793Z",
          "content": "<p>@Simeon Trieu:\nthere is a good explanation here by a French guy (in English): <a href=\"https://omoindrot.github.io/triplet-loss\">https://omoindrot.github.io/triplet-loss</a></p>\n\n<p>Edit: actually this is the first link in the top msg... sorry</p>",
          "rawMarkdown": "@Simeon Trieu:\nthere is a good explanation here by a French guy (in English): https://omoindrot.github.io/triplet-loss\n\nEdit: actually this is the first link in the top msg... sorry",
          "votes": 1
        },
        {
          "id": 452786,
          "postDate": "2019-01-09T06:46:28.907Z",
          "content": "<p>In your implementation, did you use detection to crop the image to get the score?</p>",
          "rawMarkdown": "In your implementation, did you use detection to crop the image to get the score?"
        },
        {
          "id": 452836,
          "postDate": "2019-01-09T08:15:11.807Z",
          "content": "<p>I have not used it yet. But I will try it.</p>",
          "rawMarkdown": "I have not used it yet. But I will try it."
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 449762,
      "author_name": "Tomasz Bartczak",
      "author_url": "",
      "post_date": "2019-01-03T17:46:57.183000",
      "content": "<p>I am investigating a triplet loss approach as well. The challenges I face currently is how to treat the 'new_whale' observations with this approach. I started to treat them just as negative examples but this looks limiting.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 449281,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-01-02T22:32:35.383000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 448936,
      "author_name": "",
      "author_url": "",
      "post_date": "2019-01-02T11:38:57.013000",
      "content": "<p>The triplet loss approach is pretty promising in our experiments (LB 0.78). The trick (for us) was to use the triplet loss in tensorflow.contrib. <a href=\"https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py\">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py</a></p>",
      "votes": 4,
      "replies": [
        {
          "id": 449132,
          "author_name": "hirune924",
          "author_url": "",
          "post_date": "2019-01-02T17:44:43.610000",
          "content": "<p>Thank you for your advice!!\nIn my trials, I used loss function in PyTorch. But it does not include semi hard negative mining trick. I think that it may be very important. I'm going to give it a try!! Thank you!!\n<a href=\"https://pytorch.org/docs/stable/nn.html#torch.nn.TripletMarginLoss\">https://pytorch.org/docs/stable/nn.html#torch.nn.TripletMarginLoss</a></p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 449275,
          "author_name": "Simeon Trieu",
          "author_url": "",
          "post_date": "2019-01-02T22:24:27.240000",
          "content": "<p>I'm new to metric learning, and I'd like to adopt it as my approach. What is the difference between \"Triplet Loss\" and \"Triplet Semi-Hard Loss\"? I get the basic idea of Triplet Loss, in that we are trying to push negative examples further away from positive examples by a small margin (like a SVM). So, if I am understanding this correctly, a semi-hard triplet loss is using a semi-hard negative instead of a hard negative for training? Semi-hard being a negative that is not closer to the anchor compared to the positive, but still has a non-zero loss? Thanks, @Gert-Jan and <a href=\"/hirune924\">@hirune924</a>.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 449282,
          "author_name": "eagle4",
          "author_url": "",
          "post_date": "2019-01-02T22:33:14.793000",
          "content": "<p>@Simeon Trieu:\nthere is a good explanation here by a French guy (in English): <a href=\"https://omoindrot.github.io/triplet-loss\">https://omoindrot.github.io/triplet-loss</a></p>\n\n<p>Edit: actually this is the first link in the top msg... sorry</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 452786,
          "author_name": "evan",
          "author_url": "",
          "post_date": "2019-01-09T06:46:28.907000",
          "content": "<p>In your implementation, did you use detection to crop the image to get the score?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 452836,
          "author_name": "hirune924",
          "author_url": "",
          "post_date": "2019-01-09T08:15:11.807000",
          "content": "<p>I have not used it yet. But I will try it.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "446687": "I think that Triplet loss(ReID) is a more effective approach than Classification in this problem.\nhttps://github.com/omoindrot/tensorflow-triplet-loss\nhttps://arxiv.org/abs/1503.03832\nhttp://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w6/Liao_Triplet-Based_Deep_Similarity_ICCV_2017_paper.pdf\n\nHowever、that approach does not seem to work well as shown below\nhttps://www.kaggle.com/ateplyuk/keras-triplet-loss-lb-0-224\nhttps://www.kaggle.com/ashishpatel26/triplet-loss-network-for-humpback-whale-prediction\n\nEven in my local, this approach quickly becomes over fitting. Is there anyone who tried a similar approach?",
    "449762": "I am investigating a triplet loss approach as well. The challenges I face currently is how to treat the 'new_whale' observations with this approach. I started to treat them just as negative examples but this looks limiting.",
    "449281": "",
    "448936": "The triplet loss approach is pretty promising in our experiments (LB 0.78). The trick (for us) was to use the triplet loss in tensorflow.contrib. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/losses/python/metric_learning/metric_loss_ops.py"
  }
}