{
  "id": 375897,
  "title": "9th Place Solution; Simple CNN Approach",
  "url": "/competitions/g2net-detecting-continuous-gravitational-waves/discussion/375897",
  "author_name": "yu4u",
  "post_date": "2023-01-04T00:34:45.312000",
  "votes": 48,
  "comment_count": 11,
  "views": 0,
  "content": "<p>Congrats to all prize and medal winners!<br>\nBecause the top teams got very high scores, I look forward to learning what the magic was! Anyway, I briefly introduce my simple CNN-based solution here.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F745525%2F9a2c42a8bcb46207e2bfb24013a5753f%2Fg2net.png?generation=1672792259750964&amp;alt=media\" alt=\"\"></p>\n<h2>Training data</h2>\n<p>Generating training data is very important in this competition because the given training data consists of only simulated (stationary gaussian) noises while test data contains real noises. In order to reflect the test data, I generated two types of noises; stationary noise and time-varying noise.</p>\n<ul>\n<li>Stationary noise is simply drawn from the Gaussian distribution, whose mean and std are estimated from training data.</li>\n<li>Time-varying noise is also drawn from the Gaussian distribution but its mean and std are vary with time. These parameters are calculated from test images.</li>\n<li>In addition, to simulate real noise, random walk and line noise is added to time-varying noise.</li>\n<li>Then, signal is inserted with a probability of 0.5.</li>\n<li>Finally, by deleting data at multiple timestamps, timestamp gaps in train and test data are reproduced (for both stationary noise and time-varying noise).</li>\n</ul>\n<p>The key point here is that all training data is generated online except signals. Only signals (without noise) are created with pyfstat beforehand.</p>\n<h2>Model</h2>\n<p>I trained a UNet model to predict signal positions in time-frequency domain in addition to predicting signal existence for better supervision.</p>",
  "messages": [
    {
      "id": 2085136,
      "postDate": "2023-01-04T00:34:45.313Z",
      "content": "<p>Congrats to all prize and medal winners!<br>\nBecause the top teams got very high scores, I look forward to learning what the magic was! Anyway, I briefly introduce my simple CNN-based solution here.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F745525%2F9a2c42a8bcb46207e2bfb24013a5753f%2Fg2net.png?generation=1672792259750964&amp;alt=media\" alt=\"\"></p>\n<h2>Training data</h2>\n<p>Generating training data is very important in this competition because the given training data consists of only simulated (stationary gaussian) noises while test data contains real noises. In order to reflect the test data, I generated two types of noises; stationary noise and time-varying noise.</p>\n<ul>\n<li>Stationary noise is simply drawn from the Gaussian distribution, whose mean and std are estimated from training data.</li>\n<li>Time-varying noise is also drawn from the Gaussian distribution but its mean and std are vary with time. These parameters are calculated from test images.</li>\n<li>In addition, to simulate real noise, random walk and line noise is added to time-varying noise.</li>\n<li>Then, signal is inserted with a probability of 0.5.</li>\n<li>Finally, by deleting data at multiple timestamps, timestamp gaps in train and test data are reproduced (for both stationary noise and time-varying noise).</li>\n</ul>\n<p>The key point here is that all training data is generated online except signals. Only signals (without noise) are created with pyfstat beforehand.</p>\n<h2>Model</h2>\n<p>I trained a UNet model to predict signal positions in time-frequency domain in addition to predicting signal existence for better supervision.</p>",
      "rawMarkdown": "Congrats to all prize and medal winners!\nBecause the top teams got very high scores, I look forward to learning what the magic was! Anyway, I briefly introduce my simple CNN-based solution here.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F745525%2F9a2c42a8bcb46207e2bfb24013a5753f%2Fg2net.png?generation=1672792259750964&alt=media)\n\n## Training data\n\nGenerating training data is very important in this competition because the given training data consists of only simulated (stationary gaussian) noises while test data contains real noises. In order to reflect the test data, I generated two types of noises; stationary noise and time-varying noise.\n- Stationary noise is simply drawn from the Gaussian distribution, whose mean and std are estimated from training data.\n- Time-varying noise is also drawn from the Gaussian distribution but its mean and std are vary with time. These parameters are calculated from test images.\n- In addition, to simulate real noise, random walk and line noise is added to time-varying noise.\n- Then, signal is inserted with a probability of 0.5.\n- Finally, by deleting data at multiple timestamps, timestamp gaps in train and test data are reproduced (for both stationary noise and time-varying noise).\n\nThe key point here is that all training data is generated online except signals. Only signals (without noise) are created with pyfstat beforehand.\n\n\n\n## Model\nI trained a UNet model to predict signal positions in time-frequency domain in addition to predicting signal existence for better supervision.",
      "votes": 48
    },
    {
      "id": 2087371,
      "postDate": "2023-01-05T14:55:28.493Z",
      "content": "<p>Congratulations! The signal-generation based approach helps me think on other lines.</p>",
      "rawMarkdown": "Congratulations! The signal-generation based approach helps me think on other lines.",
      "votes": 1
    },
    {
      "id": 2085442,
      "postDate": "2023-01-04T07:02:20.570Z",
      "content": "<p>Very nice! Elegant and effective.</p>",
      "rawMarkdown": "Very nice! Elegant and effective.",
      "votes": 1
    },
    {
      "id": 2085399,
      "postDate": "2023-01-04T06:29:47.840Z",
      "content": "<p>Strong and simple solution, congrats</p>",
      "rawMarkdown": "Strong and simple solution, congrats",
      "votes": 1
    },
    {
      "id": 2085225,
      "postDate": "2023-01-04T02:10:51.990Z",
      "content": "<p>Congratulations on your gold medal! Impressive solution. And congratulations on your becoming a Grandmaster!</p>\n<p>We used a large number of data augmentation and other tricks to train the CNN for classification, and the best single model only reached 0.770 LB. We attempted the UNet at the end to perhaps break through to a higher score with the location information combined, but didn't get to finish in time.</p>\n<p>I have a few questions.</p>\n<ol>\n<li><p>Is your UNet just the most original UNet? Or is it one that uses a new backbone network? Have you tested using only the first half of the network, for classification training, and how much score loss there is compared to the current method?</p></li>\n<li><p>I don't quite understand how you trained it. Why did you mention two losses in the graph, didn't you just use dice loss for training? And also take out the vector at the bottom of UNet to train the classification. How do these two heads work together? Just add the two losses together?</p></li>\n</ol>",
      "rawMarkdown": "Congratulations on your gold medal! Impressive solution. And congratulations on your becoming a Grandmaster!\n\nWe used a large number of data augmentation and other tricks to train the CNN for classification, and the best single model only reached 0.770 LB. We attempted the UNet at the end to perhaps break through to a higher score with the location information combined, but didn't get to finish in time.\n\nI have a few questions.\n1. Is your UNet just the most original UNet? Or is it one that uses a new backbone network? Have you tested using only the first half of the network, for classification training, and how much score loss there is compared to the current method?\n\n2. I don't quite understand how you trained it. Why did you mention two losses in the graph, didn't you just use dice loss for training? And also take out the vector at the bottom of UNet to train the classification. How do these two heads work together? Just add the two losses together?",
      "votes": 1,
      "replies": [
        {
          "id": 2085288,
          "postDate": "2023-01-04T03:37:40.713Z",
          "content": "<p>Thx!</p>\n<ol>\n<li>UnetPlusPlus with EfficientNetV2-s backbone. You can easily create this segmentation model with classification head as:</li>\n</ol>\n<pre><code>from segmentation_models_pytorch import UnetPlusPlus\nUnetPlusPlus(\"tu-efficientnetv2_s\", classes=1, in_channels=2, aux_params=dict(classes=1))\n</code></pre>\n<p>Best single classification model: private LB=0.786 vs. best single segmentation model: private LB=0.789.</p>\n<ol>\n<li>If I trained the model using only dice loss, some post processings are needed to calculate score from the segmentation results (or train the other model as you mentioned). Of course, these can be done, but I did not try. For the loss function, I just add the two losses.</li>\n</ol>",
          "rawMarkdown": "Thx!\n\n1. UnetPlusPlus with EfficientNetV2-s backbone. You can easily create this segmentation model with classification head as:\n\n```\nfrom segmentation_models_pytorch import UnetPlusPlus\nUnetPlusPlus(\"tu-efficientnetv2_s\", classes=1, in_channels=2, aux_params=dict(classes=1))\n```\n\nBest single classification model: private LB=0.786 vs. best single segmentation model: private LB=0.789.\n\n2. If I trained the model using only dice loss, some post processings are needed to calculate score from the segmentation results (or train the other model as you mentioned). Of course, these can be done, but I did not try. For the loss function, I just add the two losses.",
          "replies": [
            {
              "id": 2086213,
              "postDate": "2023-01-04T16:34:45.643Z",
              "content": "<p>Great solution!</p>\n<p>Would you like to share your model code for <code>UnetPlusPlus</code>? I would like to try to replicate your experiment.</p>",
              "rawMarkdown": "Great solution!\n\nWould you like to share your model code for `UnetPlusPlus`? I would like to try to replicate your experiment."
            },
            {
              "id": 2086773,
              "postDate": "2023-01-05T02:55:49.877Z",
              "content": "<p>please refer to<br>\n<a href=\"https://github.com/qubvel/segmentation_models.pytorch/blob/master/segmentation_models_pytorch/decoders/unetplusplus/model.py\" target=\"_blank\">https://github.com/qubvel/segmentation_models.pytorch/blob/master/segmentation_models_pytorch/decoders/unetplusplus/model.py</a></p>",
              "rawMarkdown": "please refer to\nhttps://github.com/qubvel/segmentation_models.pytorch/blob/master/segmentation_models_pytorch/decoders/unetplusplus/model.py"
            },
            {
              "id": 2087114,
              "postDate": "2023-01-05T10:38:48.010Z",
              "content": "<p>Thank you! </p>",
              "rawMarkdown": "Thank you! "
            }
          ]
        }
      ]
    },
    {
      "id": 2085249,
      "postDate": "2023-01-04T02:50:35.127Z",
      "content": "<p>Congrats <a href=\"https://www.kaggle.com/yu4u\" target=\"_blank\">@yu4u</a>！Very excellent solution! And congratulations on your becoming a Grandmaster!</p>",
      "rawMarkdown": "Congrats @yu4u！Very excellent solution! And congratulations on your becoming a Grandmaster!",
      "votes": 2
    },
    {
      "id": 2085192,
      "postDate": "2023-01-04T01:16:45.560Z",
      "content": "<p>Can I ask how long was your training? How many samples (generated online during training) has your model processed before you stopped the training?</p>",
      "rawMarkdown": "Can I ask how long was your training? How many samples (generated online during training) has your model processed before you stopped the training?",
      "replies": [
        {
          "id": 2085282,
          "postDate": "2023-01-04T03:24:29.017Z",
          "content": "<p>I created 20k signals beforehand, and training data for one epoch consists of 20k noise+signal and 20k noise. The model was trained for 180 epochs (it took about 18 hours). Thus, the model saw 40k * 180 examples.</p>",
          "rawMarkdown": "I created 20k signals beforehand, and training data for one epoch consists of 20k noise+signal and 20k noise. The model was trained for 180 epochs (it took about 18 hours). Thus, the model saw 40k * 180 examples.",
          "votes": 1
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 2087371,
      "author_name": "Suma Mallapragada",
      "author_url": "",
      "post_date": "2023-01-05T14:55:28.493000",
      "content": "<p>Congratulations! The signal-generation based approach helps me think on other lines.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2085442,
      "author_name": "DennisSakva",
      "author_url": "",
      "post_date": "2023-01-04T07:02:20.570000",
      "content": "<p>Very nice! Elegant and effective.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2085399,
      "author_name": "slime",
      "author_url": "",
      "post_date": "2023-01-04T06:29:47.840000",
      "content": "<p>Strong and simple solution, congrats</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2085225,
      "author_name": "Chen Lin",
      "author_url": "",
      "post_date": "2023-01-04T02:10:51.990000",
      "content": "<p>Congratulations on your gold medal! Impressive solution. And congratulations on your becoming a Grandmaster!</p>\n<p>We used a large number of data augmentation and other tricks to train the CNN for classification, and the best single model only reached 0.770 LB. We attempted the UNet at the end to perhaps break through to a higher score with the location information combined, but didn't get to finish in time.</p>\n<p>I have a few questions.</p>\n<ol>\n<li><p>Is your UNet just the most original UNet? Or is it one that uses a new backbone network? Have you tested using only the first half of the network, for classification training, and how much score loss there is compared to the current method?</p></li>\n<li><p>I don't quite understand how you trained it. Why did you mention two losses in the graph, didn't you just use dice loss for training? And also take out the vector at the bottom of UNet to train the classification. How do these two heads work together? Just add the two losses together?</p></li>\n</ol>",
      "votes": 1,
      "replies": [
        {
          "id": 2085288,
          "author_name": "yu4u",
          "author_url": "",
          "post_date": "2023-01-04T03:37:40.713000",
          "content": "<p>Thx!</p>\n<ol>\n<li>UnetPlusPlus with EfficientNetV2-s backbone. You can easily create this segmentation model with classification head as:</li>\n</ol>\n<pre><code>from segmentation_models_pytorch import UnetPlusPlus\nUnetPlusPlus(\"tu-efficientnetv2_s\", classes=1, in_channels=2, aux_params=dict(classes=1))\n</code></pre>\n<p>Best single classification model: private LB=0.786 vs. best single segmentation model: private LB=0.789.</p>\n<ol>\n<li>If I trained the model using only dice loss, some post processings are needed to calculate score from the segmentation results (or train the other model as you mentioned). Of course, these can be done, but I did not try. For the loss function, I just add the two losses.</li>\n</ol>",
          "votes": 0,
          "replies": [
            {
              "id": 2086213,
              "author_name": "Chen Lin",
              "author_url": "",
              "post_date": "2023-01-04T16:34:45.643000",
              "content": "<p>Great solution!</p>\n<p>Would you like to share your model code for <code>UnetPlusPlus</code>? I would like to try to replicate your experiment.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2086773,
              "author_name": "yu4u",
              "author_url": "",
              "post_date": "2023-01-05T02:55:49.877000",
              "content": "<p>please refer to<br>\n<a href=\"https://github.com/qubvel/segmentation_models.pytorch/blob/master/segmentation_models_pytorch/decoders/unetplusplus/model.py\" target=\"_blank\">https://github.com/qubvel/segmentation_models.pytorch/blob/master/segmentation_models_pytorch/decoders/unetplusplus/model.py</a></p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2087114,
              "author_name": "Chen Lin",
              "author_url": "",
              "post_date": "2023-01-05T10:38:48.010000",
              "content": "<p>Thank you! </p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2085249,
      "author_name": "BarryZhou",
      "author_url": "",
      "post_date": "2023-01-04T02:50:35.127000",
      "content": "<p>Congrats <a href=\"https://www.kaggle.com/yu4u\" target=\"_blank\">@yu4u</a>！Very excellent solution! And congratulations on your becoming a Grandmaster!</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2085192,
      "author_name": "GabeTheHuman",
      "author_url": "",
      "post_date": "2023-01-04T01:16:45.560000",
      "content": "<p>Can I ask how long was your training? How many samples (generated online during training) has your model processed before you stopped the training?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 2085282,
          "author_name": "yu4u",
          "author_url": "",
          "post_date": "2023-01-04T03:24:29.017000",
          "content": "<p>I created 20k signals beforehand, and training data for one epoch consists of 20k noise+signal and 20k noise. The model was trained for 180 epochs (it took about 18 hours). Thus, the model saw 40k * 180 examples.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2085136": "Congrats to all prize and medal winners!\nBecause the top teams got very high scores, I look forward to learning what the magic was! Anyway, I briefly introduce my simple CNN-based solution here.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F745525%2F9a2c42a8bcb46207e2bfb24013a5753f%2Fg2net.png?generation=1672792259750964&alt=media)\n\n## Training data\n\nGenerating training data is very important in this competition because the given training data consists of only simulated (stationary gaussian) noises while test data contains real noises. In order to reflect the test data, I generated two types of noises; stationary noise and time-varying noise.\n- Stationary noise is simply drawn from the Gaussian distribution, whose mean and std are estimated from training data.\n- Time-varying noise is also drawn from the Gaussian distribution but its mean and std are vary with time. These parameters are calculated from test images.\n- In addition, to simulate real noise, random walk and line noise is added to time-varying noise.\n- Then, signal is inserted with a probability of 0.5.\n- Finally, by deleting data at multiple timestamps, timestamp gaps in train and test data are reproduced (for both stationary noise and time-varying noise).\n\nThe key point here is that all training data is generated online except signals. Only signals (without noise) are created with pyfstat beforehand.\n\n\n\n## Model\nI trained a UNet model to predict signal positions in time-frequency domain in addition to predicting signal existence for better supervision.",
    "2087371": "Congratulations! The signal-generation based approach helps me think on other lines.",
    "2085442": "Very nice! Elegant and effective.",
    "2085399": "Strong and simple solution, congrats",
    "2085225": "Congratulations on your gold medal! Impressive solution. And congratulations on your becoming a Grandmaster!\n\nWe used a large number of data augmentation and other tricks to train the CNN for classification, and the best single model only reached 0.770 LB. We attempted the UNet at the end to perhaps break through to a higher score with the location information combined, but didn't get to finish in time.\n\nI have a few questions.\n1. Is your UNet just the most original UNet? Or is it one that uses a new backbone network? Have you tested using only the first half of the network, for classification training, and how much score loss there is compared to the current method?\n\n2. I don't quite understand how you trained it. Why did you mention two losses in the graph, didn't you just use dice loss for training? And also take out the vector at the bottom of UNet to train the classification. How do these two heads work together? Just add the two losses together?",
    "2085249": "Congrats @yu4u！Very excellent solution! And congratulations on your becoming a Grandmaster!",
    "2085192": "Can I ask how long was your training? How many samples (generated online during training) has your model processed before you stopped the training?"
  }
}