{
  "id": 452940,
  "title": "Detecting sleep using UNet(2D)",
  "url": "/competitions/child-mind-institute-detect-sleep-states/discussion/452940",
  "author_name": "213tubo",
  "post_date": "2023-11-04T06:38:05.810000",
  "votes": 206,
  "comment_count": 172,
  "views": 0,
  "content": "<p>I share my approach in this discussion.</p>\n<ul>\n<li>The code is also available on github<br>\n<a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main</a></li>\n<li>submission notebook<br>\n<a href=\"https://www.kaggle.com/code/tubotubo/cmi-submit\" target=\"_blank\">https://www.kaggle.com/code/tubotubo/cmi-submit</a></li>\n</ul>\n<h1>Model Structure</h1>\n<p>My model consists of three components: feature extractor, encoder, and decoder.</p>\n<p>The feature extractor takes the raw waveform(anglez, enmo, hour) and creates a wavegram (like an image).<br>\nThe encoder (UNet) takes the wavegrame and creates a two-dimensional heatmap.<br>\ndecoder takes the heatmap and outputs the probability(sleep, onset, wakeup) of an event occurring at each time.<br>\nFinally, post-processing is performed to create a submission file.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Ffa7f5ecfa0f290e1f44e3d2e7dbc4f06%2F(1).jpg?generation=1699079676016847&amp;alt=media\" alt=\"\"></p>\n<p>Each component has the following already implemented.</p>\n<ul>\n<li>feature extractor<ul>\n<li>CNN</li>\n<li>LSTM</li>\n<li>Spectrogram</li>\n<li><a href=\"https://arxiv.org/abs/1912.10211\" target=\"_blank\">PANNs</a></li></ul></li>\n<li>encoder<ul>\n<li>UNet</li></ul></li>\n<li>decoder<ul>\n<li>UNet1D</li>\n<li>LSTM</li>\n<li>MLP</li>\n<li>Transformer</li></ul></li>\n</ul>\n<h1>Result</h1>\n<p>LB: 0.714<br>\nfeature extractor=CNN, encoder=UNet, decoder=UNet1D, downsample_rate=2, seq_len=5760</p>\n<p>Because the code has changed since the last submission, the experiment may not be accurately reproduced with the above settings.</p>\n<h1>Tips</h1>\n<ol>\n<li>The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.<br>\n<a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/8bbc09aff9c34f12259d536fd496deaade8ec087/src/utils/metrics.py#L179\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/8bbc09aff9c34f12259d536fd496deaade8ec087/src/utils/metrics.py#L179</a></li>\n<li>Outputting a file other than submission.csv and submitting it will result in an error. In the inference notebook, it is better to leave only the final submission.csv.</li>\n</ol>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Fca7e96b19b87610f029c9b42be3b1bea%2FScreenshot%20from%202023-11-04%2016-39-08.png?generation=1699083570125882&amp;alt=media\" alt=\"\"></p>\n<h1>How to contribute</h1>\n<p>If you want to make a contribution to this repository, please write a PR or issue summary and link to it in <a href=\"https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/discussion/452940#2530545\" target=\"_blank\">this thread</a> as well to avoid private sharing.</p>",
  "messages": [
    {
      "id": 2512088,
      "postDate": "2023-11-04T06:38:05.810Z",
      "content": "<p>I share my approach in this discussion.</p>\n<ul>\n<li>The code is also available on github<br>\n<a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main</a></li>\n<li>submission notebook<br>\n<a href=\"https://www.kaggle.com/code/tubotubo/cmi-submit\" target=\"_blank\">https://www.kaggle.com/code/tubotubo/cmi-submit</a></li>\n</ul>\n<h1>Model Structure</h1>\n<p>My model consists of three components: feature extractor, encoder, and decoder.</p>\n<p>The feature extractor takes the raw waveform(anglez, enmo, hour) and creates a wavegram (like an image).<br>\nThe encoder (UNet) takes the wavegrame and creates a two-dimensional heatmap.<br>\ndecoder takes the heatmap and outputs the probability(sleep, onset, wakeup) of an event occurring at each time.<br>\nFinally, post-processing is performed to create a submission file.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Ffa7f5ecfa0f290e1f44e3d2e7dbc4f06%2F(1).jpg?generation=1699079676016847&amp;alt=media\" alt=\"\"></p>\n<p>Each component has the following already implemented.</p>\n<ul>\n<li>feature extractor<ul>\n<li>CNN</li>\n<li>LSTM</li>\n<li>Spectrogram</li>\n<li><a href=\"https://arxiv.org/abs/1912.10211\" target=\"_blank\">PANNs</a></li></ul></li>\n<li>encoder<ul>\n<li>UNet</li></ul></li>\n<li>decoder<ul>\n<li>UNet1D</li>\n<li>LSTM</li>\n<li>MLP</li>\n<li>Transformer</li></ul></li>\n</ul>\n<h1>Result</h1>\n<p>LB: 0.714<br>\nfeature extractor=CNN, encoder=UNet, decoder=UNet1D, downsample_rate=2, seq_len=5760</p>\n<p>Because the code has changed since the last submission, the experiment may not be accurately reproduced with the above settings.</p>\n<h1>Tips</h1>\n<ol>\n<li>The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.<br>\n<a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/8bbc09aff9c34f12259d536fd496deaade8ec087/src/utils/metrics.py#L179\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/8bbc09aff9c34f12259d536fd496deaade8ec087/src/utils/metrics.py#L179</a></li>\n<li>Outputting a file other than submission.csv and submitting it will result in an error. In the inference notebook, it is better to leave only the final submission.csv.</li>\n</ol>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Fca7e96b19b87610f029c9b42be3b1bea%2FScreenshot%20from%202023-11-04%2016-39-08.png?generation=1699083570125882&amp;alt=media\" alt=\"\"></p>\n<h1>How to contribute</h1>\n<p>If you want to make a contribution to this repository, please write a PR or issue summary and link to it in <a href=\"https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/discussion/452940#2530545\" target=\"_blank\">this thread</a> as well to avoid private sharing.</p>",
      "rawMarkdown": "I share my approach in this discussion.\n- The code is also available on github\nhttps://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main\n- submission notebook\nhttps://www.kaggle.com/code/tubotubo/cmi-submit\n\n# Model Structure\nMy model consists of three components: feature extractor, encoder, and decoder.\n\nThe feature extractor takes the raw waveform(anglez, enmo, hour) and creates a wavegram (like an image).\nThe encoder (UNet) takes the wavegrame and creates a two-dimensional heatmap.\ndecoder takes the heatmap and outputs the probability(sleep, onset, wakeup) of an event occurring at each time.\nFinally, post-processing is performed to create a submission file.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Ffa7f5ecfa0f290e1f44e3d2e7dbc4f06%2F(1).jpg?generation=1699079676016847&alt=media)\n\nEach component has the following already implemented.\n\n- feature extractor\n    - CNN\n    - LSTM\n    - Spectrogram\n    - [PANNs](https://arxiv.org/abs/1912.10211)\n- encoder\n    - UNet\n- decoder\n    - UNet1D\n    - LSTM\n    - MLP\n    - Transformer\n\n# Result\nLB: 0.714\nfeature extractor=CNN, encoder=UNet, decoder=UNet1D, downsample_rate=2, seq_len=5760\n\nBecause the code has changed since the last submission, the experiment may not be accurately reproduced with the above settings.\n\n# Tips\n1. The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.\nhttps://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/8bbc09aff9c34f12259d536fd496deaade8ec087/src/utils/metrics.py#L179\n2. Outputting a file other than submission.csv and submitting it will result in an error. In the inference notebook, it is better to leave only the final submission.csv.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Fca7e96b19b87610f029c9b42be3b1bea%2FScreenshot%20from%202023-11-04%2016-39-08.png?generation=1699083570125882&alt=media)\n\n# How to contribute\n\nIf you want to make a contribution to this repository, please write a PR or issue summary and link to it in [this thread](https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/discussion/452940#2530545) as well to avoid private sharing.",
      "votes": 206
    },
    {
      "id": 2512328,
      "postDate": "2023-11-04T11:24:25.490Z",
      "content": "<p>I do not believe that publicizing this approach will spoil the efforts of the other participants.<br>\nThere are two reasons.<br>\nThe first is that my approach does not encompass all other approaches. I believe that a better model can be created by combining my approach with your approach.<br>\nThe second is that the code I have published has room for many improvements and I believe there is ample time to make improvements.<br>\nFor these two reasons, I thought it was worth releasing the code and model to the public.</p>\n<p>Temporarily, LB may be full of people who just forked it, but it will be weeded out by those who are serious about experimenting.</p>",
      "rawMarkdown": "I do not believe that publicizing this approach will spoil the efforts of the other participants.\nThere are two reasons.\nThe first is that my approach does not encompass all other approaches. I believe that a better model can be created by combining my approach with your approach.\nThe second is that the code I have published has room for many improvements and I believe there is ample time to make improvements.\nFor these two reasons, I thought it was worth releasing the code and model to the public.\n\nTemporarily, LB may be full of people who just forked it, but it will be weeded out by those who are serious about experimenting.",
      "votes": 48,
      "replies": [
        {
          "id": 2512971,
          "postDate": "2023-11-05T04:21:46.723Z",
          "content": "<p>I appreciate you sharing your approach. But do I appreciate you publishing the \"CMI-submit\" notebook? I'm not sure.</p>\n<p>Just look at the LB now. So many people have 0.707 score (without putting in any effort).</p>\n<p>Your action will lead to less \"variety of solutions\". People who were working on creative approaches will give up, and focus on replicating your approach. In the end, this will reduce the variety of solutions the community develops for this competition.</p>\n<p>I don't know if this is a good thing or a bad thing.</p>",
          "rawMarkdown": "I appreciate you sharing your approach. But do I appreciate you publishing the \"CMI-submit\" notebook? I'm not sure.\n\nJust look at the LB now. So many people have 0.707 score (without putting in any effort).\n\nYour action will lead to less \"variety of solutions\". People who were working on creative approaches will give up, and focus on replicating your approach. In the end, this will reduce the variety of solutions the community develops for this competition.\n\nI don't know if this is a good thing or a bad thing.",
          "votes": 7,
          "replies": [
            {
              "id": 2512979,
              "postDate": "2023-11-05T04:46:56.670Z",
              "content": "<p>I think people need to add his approach to their own notebooks. So, solutions are getting more various and progressive.</p>",
              "rawMarkdown": "I think people need to add his approach to their own notebooks. So, solutions are getting more various and progressive."
            },
            {
              "id": 2512980,
              "postDate": "2023-11-05T04:51:32.840Z",
              "content": "<p>I have no problem with him sharing the approach.</p>\n<p>My concern is about sharing the \"CMI-submit\" notebook.</p>",
              "rawMarkdown": "I have no problem with him sharing the approach.\n\nMy concern is about sharing the \"CMI-submit\" notebook.",
              "votes": 3
            }
          ]
        },
        {
          "id": 2514892,
          "postDate": "2023-11-06T15:38:48.740Z",
          "content": "<p>Much advovated for your kind sharing <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>",
          "rawMarkdown": "Much advovated for your kind sharing @tubotubo ",
          "replies": [
            {
              "id": 2522105,
              "postDate": "2023-11-12T11:48:23.423Z",
              "content": "<p>Can you share more informations about post_process.score_th and  post_process.distance? <br>\nAnd Why use this? <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> <br>\nThanks</p>",
              "rawMarkdown": "Can you share more informations about post_process.score_th and  post_process.distance? \nAnd Why use this? @tubotubo \nThanks"
            },
            {
              "id": 2522165,
              "postDate": "2023-11-12T12:49:13.283Z",
              "content": "<p><a href=\"https://www.kaggle.com/lhchina\" target=\"_blank\">@lhchina</a> </p>\n<p>The find_peak function of scipy is used to detect events.<br>\nSee the following page for details<br>\n<a href=\"https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html\" target=\"_blank\">https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html</a><br>\n<a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/utils/post_process.py\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/utils/post_process.py</a></p>",
              "rawMarkdown": "@lhchina \n\nThe find_peak function of scipy is used to detect events.\nSee the following page for details\nhttps://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html\nhttps://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/utils/post_process.py",
              "votes": 1
            },
            {
              "id": 2522877,
              "postDate": "2023-11-13T06:07:49.673Z",
              "content": "<p>In the epochs,the valid_loss decrease,but the valid_score not increase.<br>\nlike this:<br>\nEpoch 0/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:48 • 0:00:00 2.44it/s v_num: 3vs7Epoch 0, global step 119: 'val_loss' reached 0.06178 (best 0.06178), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/checkpoints/epoch=0-step=119.ckpt' as top 1<br>\nSaved best model 0.061714774133353835 -&gt; 0.040320251738368874<br>\nEpoch 1/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.66it/s v_num: 3vs7 val_loss: 0.062 val_score: 0.000 train_loss: 0.244                                                   <br>\nEpoch 1, global step 238: 'val_loss' reached 0.04033 (best 0.04033), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/check<br>\nEpoch 2/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.85it/s v_num: 3vs7 val_loss: 0.040 val_score: 0.000 train_loss :                                                                                 0.175                                                   <br>\nSaved best model 0.040320251738368874 -&gt; 0.03305796951684632<br>\nEpoch 3/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:43 • 0:00:00 2.79it/s v_num: 3vs7 val_loss: 0.043 val_score: 0.000 train_loss:0.172                                                  <br>\nEpoch 3, global step 476: 'val_loss' reached 0.03304 (best 0.03304), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/check<br>\nEpoch 4/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:43 • 0:00:00 2.89it/s v_num: 3vs7 val_loss: 0.033 val_score: 0.000 train_loss: 0.170                                                   <br>\nEpoch 5/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.81it/s v_num: 3vs7 val_loss: 0.034 val_score: 0.000 train_loss:0.166 </p>\n<p>It was fine the first time I ran it, and then this happened</p>",
              "rawMarkdown": "In the epochs,the valid_loss decrease,but the valid_score not increase.\nlike this:\nEpoch 0/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:48 • 0:00:00 2.44it/s v_num: 3vs7Epoch 0, global step 119: 'val_loss' reached 0.06178 (best 0.06178), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/checkpoints/epoch=0-step=119.ckpt' as top 1\nSaved best model 0.061714774133353835 -> 0.040320251738368874\nEpoch 1/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.66it/s v_num: 3vs7 val_loss: 0.062 val_score: 0.000 train_loss: 0.244                                                   \nEpoch 1, global step 238: 'val_loss' reached 0.04033 (best 0.04033), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/check\nEpoch 2/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.85it/s v_num: 3vs7 val_loss: 0.040 val_score: 0.000 train_loss :                                                                                 0.175                                                   \nSaved best model 0.040320251738368874 -> 0.03305796951684632\nEpoch 3/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:43 • 0:00:00 2.79it/s v_num: 3vs7 val_loss: 0.043 val_score: 0.000 train_loss:0.172                                                  \nEpoch 3, global step 476: 'val_loss' reached 0.03304 (best 0.03304), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/check\nEpoch 4/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:43 • 0:00:00 2.89it/s v_num: 3vs7 val_loss: 0.033 val_score: 0.000 train_loss: 0.170                                                   \nEpoch 5/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.81it/s v_num: 3vs7 val_loss: 0.034 val_score: 0.000 train_loss:0.166 \n\nIt was fine the first time I ran it, and then this happened",
              "votes": 1
            },
            {
              "id": 2522885,
              "postDate": "2023-11-13T06:16:09.313Z",
              "content": "<p><a href=\"https://www.kaggle.com/lhchina\" target=\"_blank\">@lhchina</a> </p>\n<p>Please let me know what commands you have executed</p>",
              "rawMarkdown": "@lhchina \n\nPlease let me know what commands you have executed"
            },
            {
              "id": 2522897,
              "postDate": "2023-11-13T06:26:19.390Z",
              "content": "<p>python -m run.train exp_name='exp001' num_workers=2 batch_size=32 duration=5760 downsample_rate=2</p>",
              "rawMarkdown": "python -m run.train exp_name='exp001' num_workers=2 batch_size=32 duration=5760 downsample_rate=2"
            },
            {
              "id": 2522901,
              "postDate": "2023-11-13T06:33:21.183Z",
              "content": "<p><a href=\"https://www.kaggle.com/lhchina\" target=\"_blank\">@lhchina</a> </p>\n<p>The learning is going well in my environment.<br>\nPlease try git pull and then run the command again.</p>",
              "rawMarkdown": "@lhchina \n\nThe learning is going well in my environment.\nPlease try git pull and then run the command again."
            },
            {
              "id": 2523054,
              "postDate": "2023-11-13T08:07:36.253Z",
              "content": "<p>I'm trying it,maybe I change some code in the modelmodule.py.like this:<br>\nclass PLSleepModel(LightningModule):<br>\n    def <strong>init</strong>(<br>\n        self,<br>\n        cfg: TrainConfig,<br>\n        val_event_df: pl.DataFrame,<br>\n        feature_dim: int,<br>\n        num_classes: int,<br>\n        duration: int,<br>\n    ):<br>\n        super().<strong>init</strong>()<br>\n        self.cfg = cfg<br>\n        self.val_event_df = val_event_df<br>\n        num_timesteps = nearest_valid_size(int(duration * cfg.upsample_rate), cfg.downsample_rate)<br>\n        self.model = get_model(<br>\n            cfg,<br>\n            feature_dim=feature_dim,<br>\n            n_classes=num_classes,<br>\n            num_timesteps=num_timesteps // cfg.downsample_rate,<br>\n        )<br>\n        self.duration = duration<br>\n        self.validation_step_outputs: list = []<br>\n        self.__best_loss = np.inf<br>\n        self.__score = 0</p>\n<pre><code>def forward(\n    self,\n    x: torch.Tensor,\n    labels: Optional[torch.Tensor] = None,\n    do_mixup: bool = ,\n    do_cutmix: bool = ,\n) -&gt; ModelOutput:\n    return self.model(x, labels, do_mixup, do_cutmix)\n\ndef training_step(self, batch, batch_idx):\n    do_mixup = np.random.rand() &lt; self.cfg.aug.mixup_prob\n    do_cutmix = np.random.rand() &lt; self.cfg.aug.cutmix_prob\n    output = self.model(batch[], batch[], do_mixup, do_cutmix)\n\n    self.log(\n        ,\n        output.loss.detach().item(),\n        =,\n        =,\n        =,\n        =,\n    )\n    return output.loss\n\ndef validation_step(self, batch, batch_idx):\n    output = self.model.predict(batch[], self.duration, batch[])\n    self.validation_step_outputs.append(\n        (\n            batch[],\n            output.labels.detach().cpu().numpy(),\n            output.preds.detach().cpu().numpy(),\n            output.loss.detach().item(),\n        )\n    )\n    self.log(\n        ,\n        output.loss.detach().item(),\n        =,\n        =,\n        =,\n        =,\n    )\n\n    return output.loss\n\ndef on_validation_epoch_end(self):\n    keys = []\n     x  self.validation_step_outputs:\n        keys.extend(x[0])\n    labels = np.concatenate([x[1]  x  self.validation_step_outputs])\n    preds = np.concatenate([x[2]  x  self.validation_step_outputs])\n    losses = np.array([x[3]  x  self.validation_step_outputs])\n    loss = losses.mean()\n\n    val_pred_df = post_process_for_seg(\n        =keys,\n        =preds,\n        =self.cfg.pp.score_th,\n        =self.cfg.pp.distance,\n    )\n    score = event_detection_ap(self.val_event_df.to_pandas(), val_pred_df.to_pandas())\n    self.log(, score, =, =, =, =)\n\n     loss &lt; self.__best_loss:\n        #np.save(, np.array(keys))\n        #np.save(, labels)\n        #np.save(, preds)\n        val_pred_df.write_csv()\n        torch.save(self.model.state_dict(), )\n        (f)\n        self.__best_loss = loss\n\n     score &gt; self.__score:\n        torch.save(self.model.state_dict(), )\n        (f)\n        self.__score = score\n\n    self.validation_step_outputs.clear()\n</code></pre>\n<p>But I changed it back, and it still had a problem<br>\nWhen I try git pull and then run the command again.it works OK.why？</p>",
              "rawMarkdown": "I'm trying it,maybe I change some code in the modelmodule.py.like this:\nclass PLSleepModel(LightningModule):\n    def __init__(\n        self,\n        cfg: TrainConfig,\n        val_event_df: pl.DataFrame,\n        feature_dim: int,\n        num_classes: int,\n        duration: int,\n    ):\n        super().__init__()\n        self.cfg = cfg\n        self.val_event_df = val_event_df\n        num_timesteps = nearest_valid_size(int(duration * cfg.upsample_rate), cfg.downsample_rate)\n        self.model = get_model(\n            cfg,\n            feature_dim=feature_dim,\n            n_classes=num_classes,\n            num_timesteps=num_timesteps // cfg.downsample_rate,\n        )\n        self.duration = duration\n        self.validation_step_outputs: list = []\n        self.__best_loss = np.inf\n        self.__score = 0\n\n    def forward(\n        self,\n        x: torch.Tensor,\n        labels: Optional[torch.Tensor] = None,\n        do_mixup: bool = False,\n        do_cutmix: bool = False,\n    ) -> ModelOutput:\n        return self.model(x, labels, do_mixup, do_cutmix)\n\n    def training_step(self, batch, batch_idx):\n        do_mixup = np.random.rand() < self.cfg.aug.mixup_prob\n        do_cutmix = np.random.rand() < self.cfg.aug.cutmix_prob\n        output = self.model(batch[\"feature\"], batch[\"label\"], do_mixup, do_cutmix)\n\n        self.log(\n            \"train_loss\",\n            output.loss.detach().item(),\n            on_step=False,\n            on_epoch=True,\n            logger=True,\n            prog_bar=True,\n        )\n        return output.loss\n\n    def validation_step(self, batch, batch_idx):\n        output = self.model.predict(batch[\"feature\"], self.duration, batch[\"label\"])\n        self.validation_step_outputs.append(\n            (\n                batch[\"key\"],\n                output.labels.detach().cpu().numpy(),\n                output.preds.detach().cpu().numpy(),\n                output.loss.detach().item(),\n            )\n        )\n        self.log(\n            \"val_loss\",\n            output.loss.detach().item(),\n            on_step=False,\n            on_epoch=True,\n            logger=True,\n            prog_bar=True,\n        )\n\n        return output.loss\n\n    def on_validation_epoch_end(self):\n        keys = []\n        for x in self.validation_step_outputs:\n            keys.extend(x[0])\n        labels = np.concatenate([x[1] for x in self.validation_step_outputs])\n        preds = np.concatenate([x[2] for x in self.validation_step_outputs])\n        losses = np.array([x[3] for x in self.validation_step_outputs])\n        loss = losses.mean()\n\n        val_pred_df = post_process_for_seg(\n            keys=keys,\n            preds=preds,\n            score_th=self.cfg.pp.score_th,\n            distance=self.cfg.pp.distance,\n        )\n        score = event_detection_ap(self.val_event_df.to_pandas(), val_pred_df.to_pandas())\n        self.log(\"val_score\", score, on_step=False, on_epoch=True, logger=True, prog_bar=True)\n\n        if loss < self.__best_loss:\n            #np.save(\"keys.npy\", np.array(keys))\n            #np.save(\"labels.npy\", labels)\n            #np.save(\"preds.npy\", preds)\n            val_pred_df.write_csv(\"val_pred_df.csv\")\n            torch.save(self.model.state_dict(), \"best_model.pth\")\n            print(f\"Saved best model {self.__best_loss} -> {loss}\")\n            self.__best_loss = loss\n\n        if score > self.__score:\n            torch.save(self.model.state_dict(), \"best_model_score.pth\")\n            print(f\"Saved best model {self.__score} -> {score}\")\n            self.__score = score\n\n        self.validation_step_outputs.clear()\n\nBut I changed it back, and it still had a problem\nWhen I try git pull and then run the command again.it works OK.why？"
            }
          ]
        },
        {
          "id": 2525315,
          "postDate": "2023-11-15T03:10:27.373Z",
          "rawMarkdown": "",
          "votes": 1,
          "isDeleted": true,
          "replies": [
            {
              "id": 2525322,
              "postDate": "2023-11-15T03:21:40.413Z",
              "content": "<p>I do think sharing the strategy and showing the potential was helpful but I do wish that the inference notebook was not shared. I think the leaderboard is filled with forks of this inference notebook. I would think that this was still ok if there was a training notebook that would actually work on kaggle so the masses would be able to play and learn from it. I was able to do so but I fear most will not have. </p>",
              "rawMarkdown": "I do think sharing the strategy and showing the potential was helpful but I do wish that the inference notebook was not shared. I think the leaderboard is filled with forks of this inference notebook. I would think that this was still ok if there was a training notebook that would actually work on kaggle so the masses would be able to play and learn from it. I was able to do so but I fear most will not have. ",
              "votes": 2
            }
          ]
        }
      ]
    },
    {
      "id": 2530561,
      "postDate": "2023-11-19T09:04:18.357Z",
      "content": "<p>I've implemented a few additional models, so if you're interested, give it a try!</p>\n<h1>Implemented models</h1>\n<p>The model is built with two components: feature_extractor and decoder.</p>\n<p>The feature_extractor and decoder that can be specified are as follows</p>\n<h3>Feature Extractor</h3>\n<ul>\n<li><a href=\"https://github.com/analokmaus/kaggle-g2net-public/tree/main/models1d_pytorch\" target=\"_blank\">CNNSpectrogram</a></li>\n<li>LSTMFeatureExtractor</li>\n<li><a href=\"https://arxiv.org/abs/1912.10211\" target=\"_blank\">PANNsFeatureExtractor</a></li>\n<li>SpecFeatureExtractor</li>\n</ul>\n<h3>Decoder</h3>\n<ul>\n<li>MLPDecoder</li>\n<li>LSTMDecoder</li>\n<li>TransformerDecoder</li>\n<li>TransformerCNNDecoder</li>\n<li><a href=\"https://github.com/bamps53/kaggle-dfl-3rd-place-solution/blob/master/models/cnn_3d.py\" target=\"_blank\">UNet1DDecoder</a></li>\n<li>MLPDecoder</li>\n</ul>\n<h3>Model</h3>\n<ul>\n<li>Spec2DCNN: Segmentation through UNet.</li>\n<li>Spec1D: Segmentation without UNet</li>\n<li>DETR2DCNN: Use UNet to detect sleep as in <a href=\"https://arxiv.org/abs/2005.12872\" target=\"_blank\">DETR</a>. This model is still under development.</li>\n<li>CenterNet: Detect onset and offset, respectively, like <a href=\"https://arxiv.org/abs/1904.07850\" target=\"_blank\">CenterNet</a> using UNet</li>\n<li>TransformerAutoModel: <ul>\n<li>Segmentation using huggingface's <a href=\"https://huggingface.co/transformers/v3.0.2/model_doc/auto.html\" target=\"_blank\">AutoModel</a>. don't use feature_extractor and decoder.</li>\n<li>Since the Internet is not available during inference, it is necessary to create a config dataset and specify the path in the model_name.</li></ul></li>\n</ul>\n<p>The correspondence table between each model and dataset is as follows.</p>\n<table>\n<thead>\n<tr>\n<th>model</th>\n<th>dataset</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Spec1D</td>\n<td>seg</td>\n</tr>\n<tr>\n<td>Spec2DCNN</td>\n<td>seg</td>\n</tr>\n<tr>\n<td>DETR2DCNN</td>\n<td>detr</td>\n</tr>\n<tr>\n<td>CenterNet</td>\n<td>centernet</td>\n</tr>\n<tr>\n<td>TransformerAutoModel</td>\n<td>seg</td>\n</tr>\n</tbody>\n</table>\n<p>The command to train CenterNet with feature_extractor=CNNSpectrogram, decoder=UNet1DDecoder is as follows</p>\n<pre><code>rye run python run/train.py model=CenterNet dataset=centernet feature_extractor=CNNSpectrogram decoder=UNet1DDecoder\n</code></pre>",
      "rawMarkdown": "I've implemented a few additional models, so if you're interested, give it a try!\n\n# Implemented models\n\nThe model is built with two components: feature_extractor and decoder.\n\nThe feature_extractor and decoder that can be specified are as follows\n\n### Feature Extractor\n\n- [CNNSpectrogram](https://github.com/analokmaus/kaggle-g2net-public/tree/main/models1d_pytorch)\n- LSTMFeatureExtractor\n- [PANNsFeatureExtractor](https://arxiv.org/abs/1912.10211)\n- SpecFeatureExtractor\n\n### Decoder\n\n- MLPDecoder\n- LSTMDecoder\n- TransformerDecoder\n- TransformerCNNDecoder\n- [UNet1DDecoder](https://github.com/bamps53/kaggle-dfl-3rd-place-solution/blob/master/models/cnn_3d.py)\n- MLPDecoder\n\n### Model\n\n- Spec2DCNN: Segmentation through UNet.\n- Spec1D: Segmentation without UNet\n- DETR2DCNN: Use UNet to detect sleep as in [DETR](https://arxiv.org/abs/2005.12872). This model is still under development.\n- CenterNet: Detect onset and offset, respectively, like [CenterNet](https://arxiv.org/abs/1904.07850) using UNet\n- TransformerAutoModel: \n  - Segmentation using huggingface's [AutoModel](https://huggingface.co/transformers/v3.0.2/model_doc/auto.html). don't use feature_extractor and decoder.\n  -  Since the Internet is not available during inference, it is necessary to create a config dataset and specify the path in the model_name.\n\nThe correspondence table between each model and dataset is as follows.\n\n| model     | dataset   | \n| --------- | --------- | \n| Spec1D    | seg       | \n| Spec2DCNN | seg       | \n| DETR2DCNN | detr      | \n| CenterNet | centernet | \n| TransformerAutoModel | seg |\n\nThe command to train CenterNet with feature_extractor=CNNSpectrogram, decoder=UNet1DDecoder is as follows\n\n```bash\nrye run python run/train.py model=CenterNet dataset=centernet feature_extractor=CNNSpectrogram decoder=UNet1DDecoder\n```",
      "votes": 18,
      "replies": [
        {
          "id": 2530890,
          "postDate": "2023-11-19T16:11:19.633Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 2533104,
          "postDate": "2023-11-21T15:31:32.360Z",
          "content": "<p>That's a incredible sharing, appreciate your consistent yet high-quality work !</p>",
          "rawMarkdown": "That's a incredible sharing, appreciate your consistent yet high-quality work !",
          "votes": 1
        },
        {
          "id": 2542049,
          "postDate": "2023-11-29T03:19:39.230Z",
          "rawMarkdown": "",
          "isDeleted": true,
          "replies": [
            {
              "id": 2542055,
              "postDate": "2023-11-29T03:29:25.887Z",
              "rawMarkdown": "",
              "isDeleted": true
            },
            {
              "id": 2542056,
              "postDate": "2023-11-29T03:30:13.360Z",
              "rawMarkdown": "",
              "isDeleted": true
            }
          ]
        }
      ]
    },
    {
      "id": 2512132,
      "postDate": "2023-11-04T07:40:28.203Z",
      "content": "<p>I don't know whether I should be happy or sad now</p>",
      "rawMarkdown": "I don't know whether I should be happy or sad now",
      "votes": 17,
      "replies": [
        {
          "id": 2512135,
          "postDate": "2023-11-04T07:47:24.280Z",
          "content": "<p>I feel exactly the same, I was working very hardly to climb up the ranks and I just got a top50 submission few hours ago which I was very happy about. Then I find this lol. I just see it as a way to ruin the lb and it's not considerate of people's efforts, I mean it's a top 20 submission with a month until the competition ends?.  But then I had to hop on the train since everyone is going to hop on it now. </p>",
          "rawMarkdown": "I feel exactly the same, I was working very hardly to climb up the ranks and I just got a top50 submission few hours ago which I was very happy about. Then I find this lol. I just see it as a way to ruin the lb and it's not considerate of people's efforts, I mean it's a top 20 submission with a month until the competition ends?.  But then I had to hop on the train since everyone is going to hop on it now. ",
          "votes": 8,
          "replies": [
            {
              "id": 2512186,
              "postDate": "2023-11-04T08:17:23.507Z",
              "rawMarkdown": "",
              "votes": 3,
              "isDeleted": true
            },
            {
              "id": 2512267,
              "postDate": "2023-11-04T10:05:07.753Z",
              "rawMarkdown": "",
              "votes": 14,
              "isDeleted": true
            },
            {
              "id": 2512432,
              "postDate": "2023-11-04T14:10:48.743Z",
              "content": "<p>100% agree, I think sharing methods and approaches is perfectly fine (up to a certain point in the competition). But what is the point in enabling others to just submit a pre-trained model? At least the people who actually replicate the methods put in <strong>some</strong> effort to do that.</p>",
              "rawMarkdown": "100% agree, I think sharing methods and approaches is perfectly fine (up to a certain point in the competition). But what is the point in enabling others to just submit a pre-trained model? At least the people who actually replicate the methods put in **some** effort to do that.",
              "votes": 2
            },
            {
              "id": 2514052,
              "postDate": "2023-11-06T01:58:47.770Z",
              "content": "<p>The rule \"Don't share the trained weight that scores high and may ruin the LB after a certain point in a competition\" is very obscure. As you know, in the competition's rule there are no explicit threshold in terms of score, the definition of ruining the LB, and when the certain point starts. If you hate it, you need to choose a competition that has such restrictions in the rule explicitly. (However, in kaggle at this moment, you can find no such competitions, I suppose. ) </p>",
              "rawMarkdown": "The rule \"Don't share the trained weight that scores high and may ruin the LB after a certain point in a competition\" is very obscure. As you know, in the competition's rule there are no explicit threshold in terms of score, the definition of ruining the LB, and when the certain point starts. If you hate it, you need to choose a competition that has such restrictions in the rule explicitly. (However, in kaggle at this moment, you can find no such competitions, I suppose. ) "
            }
          ]
        },
        {
          "id": 2525323,
          "postDate": "2023-11-15T03:24:25.870Z",
          "rawMarkdown": "",
          "votes": 1,
          "isDeleted": true
        }
      ]
    },
    {
      "id": 2513149,
      "postDate": "2023-11-05T08:19:30.167Z",
      "content": "<p>If you want to install Rye in a Kaggle notebook, use this command:<br>\n<code>curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION=\"--yes\" bash</code><br>\ninstead of<br>\n<code>curl -sSf https://rye-up.com/get | bash</code></p>\n<p>(see <a href=\"https://github.com/mitsuhiko/rye/issues/246\" target=\"_blank\">https://github.com/mitsuhiko/rye/issues/246</a> for details)</p>",
      "rawMarkdown": "If you want to install Rye in a Kaggle notebook, use this command:\n```curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION=\"--yes\" bash```\ninstead of\n```curl -sSf https://rye-up.com/get | bash```\n\n(see https://github.com/mitsuhiko/rye/issues/246 for details)",
      "votes": 11,
      "replies": [
        {
          "id": 2514292,
          "postDate": "2023-11-06T07:03:59.203Z",
          "content": "<p>Another note: if you want to run <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> code in a Kaggle notebook, you should change this line in <code>pyproject.toml</code>:<br>\n<code>url = \"https://download.pytorch.org/whl/cu120\"</code><br>\nto<br>\n<code>url = \"https://download.pytorch.org/whl/cu118\"</code><br>\nsince Kaggle environment currently has CUDA 11.4 installed.</p>",
          "rawMarkdown": "Another note: if you want to run @tubotubo code in a Kaggle notebook, you should change this line in `pyproject.toml`:\n```url = \"https://download.pytorch.org/whl/cu120\"```\nto\n```url = \"https://download.pytorch.org/whl/cu118\"```\nsince Kaggle environment currently has CUDA 11.4 installed.",
          "votes": 7,
          "replies": [
            {
              "id": 2519541,
              "postDate": "2023-11-10T06:29:05.023Z",
              "content": "<p>In the kaggle,I meet this question in trainning phase，and how to deal with it?<br>\nOriginal Traceback (most recent call last):<br>\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py\", line 308, in _worker_loop<br>\n    data = fetcher.fetch(index)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py\", line 51, in fetch<br>\n    data = [self.dataset[idx] for idx in possibly_batched_index]<br>\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py\", line 51, in <br>\n    data = [self.dataset[idx] for idx in possibly_batched_index]<br>\n  File \"/kaggle/input/cmi-code/cmi-code/src/dataset/seg.py\", line 106, in <strong>getitem</strong><br>\n    label = get_seg_label(this_event_df, num_frames, self.cfg.duration, start, end)<br>\n  File \"/kaggle/input/cmi-code/cmi-code/src/dataset/seg.py\", line 21, in get_seg_label<br>\n    this_event_df = this_event_df.query(\"@start &lt;= wakeup &amp; onset &lt;= <a href=\"https://www.kaggle.com/end\" target=\"_blank\">@end</a>\")<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/frame.py\", line 4440, in query<br>\n    res = self.eval(expr, **kwargs)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/frame.py\", line 4566, in eval<br>\n    return _eval(expr, inplace=inplace, **kwargs)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/eval.py\", line 357, in eval<br>\n    ret = eng_inst.evaluate()<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/engines.py\", line 81, in evaluate<br>\n    res = self._evaluate()<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/engines.py\", line 121, in _evaluate<br>\n    return ne.evaluate(s, local_dict=scope)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 943, in evaluate<br>\n    raise e<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 851, in validate<br>\n    _names_cache[expr_key] = getExprNames(ex, context)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 714, in getExprNames<br>\n    ex = stringToExpression(text, {}, context)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 274, in stringToExpression<br>\n    raise ValueError(f'Expression {s} has forbidden control characters.')<br>\nValueError: Expression ((__pd_eval_local_start) &lt;= (wakeup)) &amp; ((onset) &lt;= (__pd_eval_local_end)) has forbidden control characters.</p>",
              "rawMarkdown": "In the kaggle,I meet this question in trainning phase，and how to deal with it?\nOriginal Traceback (most recent call last):\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py\", line 308, in _worker_loop\n    data = fetcher.fetch(index)\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py\", line 51, in fetch\n    data = [self.dataset[idx] for idx in possibly_batched_index]\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py\", line 51, in <listcomp>\n    data = [self.dataset[idx] for idx in possibly_batched_index]\n  File \"/kaggle/input/cmi-code/cmi-code/src/dataset/seg.py\", line 106, in __getitem__\n    label = get_seg_label(this_event_df, num_frames, self.cfg.duration, start, end)\n  File \"/kaggle/input/cmi-code/cmi-code/src/dataset/seg.py\", line 21, in get_seg_label\n    this_event_df = this_event_df.query(\"@start <= wakeup & onset <= @end\")\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/frame.py\", line 4440, in query\n    res = self.eval(expr, **kwargs)\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/frame.py\", line 4566, in eval\n    return _eval(expr, inplace=inplace, **kwargs)\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/eval.py\", line 357, in eval\n    ret = eng_inst.evaluate()\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/engines.py\", line 81, in evaluate\n    res = self._evaluate()\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/engines.py\", line 121, in _evaluate\n    return ne.evaluate(s, local_dict=scope)\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 943, in evaluate\n    raise e\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 851, in validate\n    _names_cache[expr_key] = getExprNames(ex, context)\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 714, in getExprNames\n    ex = stringToExpression(text, {}, context)\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 274, in stringToExpression\n    raise ValueError(f'Expression {s} has forbidden control characters.')\nValueError: Expression ((__pd_eval_local_start) <= (wakeup)) & ((onset) <= (__pd_eval_local_end)) has forbidden control characters."
            },
            {
              "id": 2519984,
              "postDate": "2023-11-10T13:54:27.517Z",
              "content": "<p>In the query method of pandas, local variables are referenced in strings using the @ symbol. However, this method can sometimes lead to errors. Instead, consider a method that directly computes and filters data frame conditions.</p>\n<p>The epochs is set to 50, but in my case, the epochs went out of memory at 23. Please let me know if you have any solutions.</p>",
              "rawMarkdown": "In the query method of pandas, local variables are referenced in strings using the @ symbol. However, this method can sometimes lead to errors. Instead, consider a method that directly computes and filters data frame conditions.\n\nThe epochs is set to 50, but in my case, the epochs went out of memory at 23. Please let me know if you have any solutions."
            },
            {
              "id": 2520118,
              "postDate": "2023-11-10T15:31:02.497Z",
              "content": "<p>The version of the code may be different.<br>\nTry git pull to use the latest code.</p>",
              "rawMarkdown": "The version of the code may be different.\nTry git pull to use the latest code.",
              "votes": 2
            },
            {
              "id": 2520130,
              "postDate": "2023-11-10T15:43:08.423Z",
              "content": "<p>I noticed that you recently had updated the code - it now includes detr2D. Can you specify a source of this architecture?</p>",
              "rawMarkdown": "I noticed that you recently had updated the code - it now includes detr2D. Can you specify a source of this architecture?"
            },
            {
              "id": 2520145,
              "postDate": "2023-11-10T15:53:24.340Z",
              "content": "<p><a href=\"https://www.kaggle.com/atamazian\" target=\"_blank\">@atamazian</a> </p>\n<p>This architecture is called DETR.<br>\nI have implemented it for study purposes, but have not yet achieved good accuracy.</p>\n<p><a href=\"https://arxiv.org/abs/2005.12872\" target=\"_blank\">https://arxiv.org/abs/2005.12872</a></p>",
              "rawMarkdown": "@atamazian \n\nThis architecture is called DETR.\nI have implemented it for study purposes, but have not yet achieved good accuracy.\n \nhttps://arxiv.org/abs/2005.12872",
              "votes": 3
            },
            {
              "id": 2520174,
              "postDate": "2023-11-10T16:19:20.107Z",
              "rawMarkdown": "",
              "isDeleted": true
            },
            {
              "id": 2520759,
              "postDate": "2023-11-11T06:42:15.040Z",
              "content": "<p>When I install rye in the kaggle, something wrong. and how to create virtual environment?<br>\n<a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>\n<p>!cp -r /kaggle/input/cmi-code/cmi-code cmi-code <br>\n!pip install hydra-core segmentation_models_pytorch==0.3.3 --no-index --find-links=/kaggle/input/ex-library<br>\n!curl -sSf <a href=\"https://rye-up.com/get\" target=\"_blank\">https://rye-up.com/get</a> | RYE_INSTALL_OPTION=\"--yes\" bash<br>\n!echo 'source \"$HOME/.rye/env\"' &gt;&gt; ~/.bashrc<br>\n!source ~/.bashrc</p>\n<p>This installer will install rye to /root/.rye<br>\nThis path can be changed by exporting the RYE_HOME environment variable.<br>\nDetails:<br>\n  Rye Version: 0.15.2<br>\n  Platform: linux (x86_64)<br>\nInstalled binary to /root/.rye/shims/rye<br>\nBootstrapping rye internals<br>\nDownloading cpython@3.11.6<br>\nChecking checksum██████████████████████████████░░░░ 49.16 MiB/52.29 MiB<br>\nsuccess: Downloaded cpython@3.11.6<br>\nUpgrading pip<br>\nInstalling internal dependencies<br>\nUpdated self-python installation at /root/.rye/self</p>\n<p>The rye directory /root/.rye/shims was not detected on PATH.<br>\nIt is highly recommended that you add it.<br>\nAdd this at the end of your .profile, .zprofile or similar:<br>\n    source \"$HOME/.rye/env\"<br>\nNote: after adding rye to your path, restart your shell for it to take effect.</p>\n<p>!rye sync<br>\n/bin/bash: line 1: rye: command not found</p>",
              "rawMarkdown": "When I install rye in the kaggle, something wrong. and how to create virtual environment?\n@tubotubo \n\n!cp -r /kaggle/input/cmi-code/cmi-code cmi-code \n!pip install hydra-core segmentation_models_pytorch==0.3.3 --no-index --find-links=/kaggle/input/ex-library\n!curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION=\"--yes\" bash\n!echo 'source \"$HOME/.rye/env\"' >> ~/.bashrc\n!source ~/.bashrc\n\nThis installer will install rye to /root/.rye\nThis path can be changed by exporting the RYE_HOME environment variable.\nDetails:\n  Rye Version: 0.15.2\n  Platform: linux (x86_64)\nInstalled binary to /root/.rye/shims/rye\nBootstrapping rye internals\nDownloading cpython@3.11.6\nChecking checksum██████████████████████████████░░░░ 49.16 MiB/52.29 MiB\nsuccess: Downloaded cpython@3.11.6\nUpgrading pip\nInstalling internal dependencies\nUpdated self-python installation at /root/.rye/self\n\nThe rye directory /root/.rye/shims was not detected on PATH.\nIt is highly recommended that you add it.\nAdd this at the end of your .profile, .zprofile or similar:\n    source \"$HOME/.rye/env\"\nNote: after adding rye to your path, restart your shell for it to take effect.\n\n!rye sync\n/bin/bash: line 1: rye: command not found"
            },
            {
              "id": 2520793,
              "postDate": "2023-11-11T07:12:29Z",
              "content": "<p>try <code>!/root/.rye/shims/rye sync</code> instead</p>",
              "rawMarkdown": "try `!/root/.rye/shims/rye sync` instead",
              "votes": 3
            }
          ]
        }
      ]
    },
    {
      "id": 2512169,
      "postDate": "2023-11-04T08:08:51.597Z",
      "content": "<p>It's a great share but may not at a right time.</p>",
      "rawMarkdown": "It's a great share but may not at a right time.",
      "votes": 9
    },
    {
      "id": 2514836,
      "postDate": "2023-11-06T15:03:16.080Z",
      "content": "<p><a href=\"https://www.kaggle.com/tubo\" target=\"_blank\">@tubo</a></p>\n<p>Thank you for sharing gold-standard solution.</p>\n<blockquote>\n  <p>The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.</p>\n</blockquote>\n<p>FYI, about the bisect search part, I rewrite the original logic. Although computation time is not boosted much, I think the logic became simpler and clearer.</p>\n<pre><code> ():\n    \n    \n    idx = bisect_left(gt_times, det_time)\n\n    best_idx = \n    best_error = ()\n\n    range_min = (, idx - )\n    range_max = ((gt_times), idx + )\n     check_idx  (range_min, range_max):  \n         check_idx   excluded_indices:\n            error = (gt_times[check_idx] - det_time)\n             error &lt; best_error:\n                best_error = error\n                best_idx = check_idx\n\n     best_idx, best_error\n</code></pre>",
      "rawMarkdown": "@tubo\n\nThank you for sharing gold-standard solution.\n\n> The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.\n\nFYI, about the bisect search part, I rewrite the original logic. Although computation time is not boosted much, I think the logic became simpler and clearer.\n\n```\ndef find_nearest_time_idx(gt_times, det_time, excluded_indices: set):\n    \"\"\"\n    search index of gt_times closest to det_time.\n\n    assumes gt_times is sorted in ascending order.\n    \"\"\"\n    # e.g. if gt_times = [0, 1, 2, 3, 4, 5] and det_time = 2.5, then idx = 3\n    idx = bisect_left(gt_times, det_time)\n\n    best_idx = None\n    best_error = float(\"inf\")\n\n    range_min = max(0, idx - 1)\n    range_max = min(len(gt_times), idx + 2)\n    for check_idx in range(range_min, range_max):  # Check the exact, one before, and one after\n        if check_idx not in excluded_indices:\n            error = abs(gt_times[check_idx] - det_time)\n            if error < best_error:\n                best_error = error\n                best_idx = check_idx\n\n    return best_idx, best_error\n```",
      "votes": 7,
      "replies": [
        {
          "id": 2514885,
          "postDate": "2023-11-06T15:32:58.920Z",
          "content": "<p>Thanks for the good refactoring!</p>",
          "rawMarkdown": "Thanks for the good refactoring!",
          "votes": 2
        },
        {
          "id": 2516831,
          "postDate": "2023-11-08T02:24:23.530Z",
          "content": "<p>The above code doesn't handle the case if the closest time_step is already matched.<br>\nWe should remove already matched gt indices from list of candidates.</p>\n<p>Since my own prediction code predicts at most 1 event pair per night, it produces the same result, but it should be problematic in general cases.</p>\n<pre><code> ():\n    \n    idx = np.searchsorted(xs, value, side=)\n    best_idx = \n    best_error = ()\n\n    range_min = (, idx - )\n    range_max = ((xs), idx + )\n     check_idx  (\n        range_min, range_max\n    ):  \n        error = (xs[check_idx] - value)\n         error &lt; best_error:\n            best_error = error\n            best_idx = check_idx\n\n     best_idx, best_error\n\n\n ():\n    \n    \n    sorted_gt_times = np.asarray(sorted_gt_times)\n    available_indices = np.asarray(\n        ((((sorted_gt_times))) - excluded_indices), dtype=\n    )\n    sorted_gt_times = sorted_gt_times[available_indices]\n    idx, error = find_nearest(sorted_gt_times, det_time)\n\n     idx  :\n         , ()\n\n     available_indices[idx], error\n</code></pre>",
          "rawMarkdown": "The above code doesn't handle the case if the closest time_step is already matched.\nWe should remove already matched gt indices from list of candidates.\n\nSince my own prediction code predicts at most 1 event pair per night, it produces the same result, but it should be problematic in general cases.\n\n```python\ndef find_nearest(xs: np.ndarray, value):\n    \"\"\"\n    Find the index of the closest value to x in the array xs.\n    \"\"\"\n    idx = np.searchsorted(xs, value, side=\"left\")\n    best_idx = None\n    best_error = float(\"inf\")\n\n    range_min = max(0, idx - 1)\n    range_max = min(len(xs), idx + 2)\n    for check_idx in range(\n        range_min, range_max\n    ):  # Check the exact, one before, and one after\n        error = abs(xs[check_idx] - value)\n        if error < best_error:\n            best_error = error\n            best_idx = check_idx\n\n    return best_idx, best_error\n\n\ndef find_nearest_time_idx(sorted_gt_times, det_time, excluded_indices: set):\n    \"\"\"\n    search index of gt_times closest to det_time.\n\n    assumes gt_times is sorted in ascending order.\n    \"\"\"\n    # e.g. if gt_times = [0, 1, 2, 3, 4, 5] and det_time = 2.5, then idx = 3\n    sorted_gt_times = np.asarray(sorted_gt_times)\n    available_indices = np.asarray(\n        sorted(set(range(len(sorted_gt_times))) - excluded_indices), dtype=int\n    )\n    sorted_gt_times = sorted_gt_times[available_indices]\n    idx, error = find_nearest(sorted_gt_times, det_time)\n\n    if idx is None:\n        return None, float(\"inf\")\n\n    return available_indices[idx], error\n```",
          "votes": 5
        }
      ]
    },
    {
      "id": 2512434,
      "postDate": "2023-11-04T14:15:24.720Z",
      "content": "<blockquote>\n  <p>I do not believe that publicizing this approach will spoil the efforts of the other participants.</p>\n</blockquote>\n<p>I have to disagree. If you would have just published this post, or maybe even the code, you could maybe argue that. But why publish the weights of a model that scores this high? Especially after there is just one month left. I really don't see the point in that…</p>",
      "rawMarkdown": ">I do not believe that publicizing this approach will spoil the efforts of the other participants.\n\nI have to disagree. If you would have just published this post, or maybe even the code, you could maybe argue that. But why publish the weights of a model that scores this high? Especially after there is just one month left. I really don't see the point in that...",
      "votes": 9,
      "replies": [
        {
          "id": 2512469,
          "postDate": "2023-11-04T14:48:10.367Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 2512489,
          "postDate": "2023-11-04T15:08:00.163Z",
          "content": "<p>Assume that the training code is allowed to be published.</p>\n<p>If the training code is not publicly available, I do not think it is permissible to publish the model weights. If you don't publish the training code, you are not providing any value to the platform.<br>\nHowever, if the training code is to be made public, the weights of the model may or may not be made public.<br>\nAs long as the training code is publicly available, I think you are providing value to the platform.<br>\nI also think there is little difference between just forking the training code and submitting and using the published weights.</p>\n<p>I think this discussion is a difference of ideas, so I will not discuss it further.</p>",
          "rawMarkdown": "Assume that the training code is allowed to be published.\n\nIf the training code is not publicly available, I do not think it is permissible to publish the model weights. If you don't publish the training code, you are not providing any value to the platform.\nHowever, if the training code is to be made public, the weights of the model may or may not be made public.\nAs long as the training code is publicly available, I think you are providing value to the platform.\nI also think there is little difference between just forking the training code and submitting and using the published weights.\n\nI think this discussion is a difference of ideas, so I will not discuss it further.",
          "replies": [
            {
              "id": 2512548,
              "postDate": "2023-11-04T16:20:11.083Z",
              "content": "<blockquote>\n  <p>However, if the training code is to be made public, the weights of the model may or may not be made public.</p>\n</blockquote>\n<p>Exactly, but one results in much more \"forkmittings\" than the other. Much fewer people actually go out of their way and train the model and then submit it. And I know that it can be frustrating for someone that put a lot of effort into making a 50th place submission, to be 300th place the next day. That's why I also think you should be careful with publishing training code, especially 1 month before end, which I think is relatively late for the impact it has. I believe a lot of people love the competitive aspect of it, but realistically, that is gone for many people when anything past the top 2% might come from someone who has never touched a machine learning model in their life.</p>\n<p>Also, I wonder why you last submission is one month ago? Couldn't you have published the code back then?</p>",
              "rawMarkdown": "> However, if the training code is to be made public, the weights of the model may or may not be made public.\n\nExactly, but one results in much more \"forkmittings\" than the other. Much fewer people actually go out of their way and train the model and then submit it. And I know that it can be frustrating for someone that put a lot of effort into making a 50th place submission, to be 300th place the next day. That's why I also think you should be careful with publishing training code, especially 1 month before end, which I think is relatively late for the impact it has. I believe a lot of people love the competitive aspect of it, but realistically, that is gone for many people when anything past the top 2% might come from someone who has never touched a machine learning model in their life.\n\nAlso, I wonder why you last submission is one month ago? Couldn't you have published the code back then?",
              "votes": 13
            },
            {
              "id": 2512558,
              "postDate": "2023-11-04T16:35:14.577Z",
              "content": "<blockquote>\n  <p>Much fewer people actually go out of their way and train the model and then submit it. </p>\n</blockquote>\n<p>I am skeptical on this point.<br>\nSimply using published weights is difficult to maintain a high ranking. For a time, more people may use the published weights, but I believe that gradually more people will use the weights from the improved model using the training code.</p>\n<blockquote>\n  <p>Also, I wonder why you last submission is one month ago? Couldn't you have published the code back then?</p>\n</blockquote>\n<p>The reason is that a month ago my goal was to win this competition. However, I got busy and decided to withdraw from this competition. Therefore, I decided to publish the code I wrote a month ago.</p>",
              "rawMarkdown": "> Much fewer people actually go out of their way and train the model and then submit it. \n\nI am skeptical on this point.\nSimply using published weights is difficult to maintain a high ranking. For a time, more people may use the published weights, but I believe that gradually more people will use the weights from the improved model using the training code.\n\n> Also, I wonder why you last submission is one month ago? Couldn't you have published the code back then?\n\nThe reason is that a month ago my goal was to win this competition. However, I got busy and decided to withdraw from this competition. Therefore, I decided to publish the code I wrote a month ago.",
              "votes": 2
            }
          ]
        },
        {
          "id": 2513068,
          "postDate": "2023-11-05T06:48:47.603Z",
          "content": "<p>Dude, the remained one month is just a start for the competitions. There still a lot people just began their work just now. If you wish to keep your efforts, you should ask hosts to close the \"join button\".</p>",
          "rawMarkdown": "Dude, the remained one month is just a start for the competitions. There still a lot people just began their work just now. If you wish to keep your efforts, you should ask hosts to close the \"join button\".",
          "votes": -2
        }
      ]
    },
    {
      "id": 2512388,
      "postDate": "2023-11-04T13:23:18.197Z",
      "content": "<p>This is my impression from the experiments I have done, the 2D approach is not that important.<br>\nIt would be more accurate to capture more detailed information in the time direction rather than frequency.<br>\nThis means that the 1D approach may be better than the 2D approach.</p>",
      "rawMarkdown": "This is my impression from the experiments I have done, the 2D approach is not that important.\nIt would be more accurate to capture more detailed information in the time direction rather than frequency.\nThis means that the 1D approach may be better than the 2D approach.",
      "votes": 5,
      "replies": [
        {
          "id": 2512497,
          "postDate": "2023-11-04T15:15:51.897Z",
          "content": "<p>It's hard to say. For example, I'm using 1d approach, but my best result is just LB 0.639 for now.</p>",
          "rawMarkdown": "It's hard to say. For example, I'm using 1d approach, but my best result is just LB 0.639 for now.",
          "replies": [
            {
              "id": 2512566,
              "postDate": "2023-11-04T16:45:12.567Z",
              "content": "<p>Look at rank #19 , he's using 1D approach at LB 0.718</p>",
              "rawMarkdown": "Look at rank #19 , he's using 1D approach at LB 0.718",
              "votes": 1
            }
          ]
        }
      ]
    },
    {
      "id": 2538861,
      "postDate": "2023-11-26T14:01:36.833Z",
      "content": "<p>Thank you for your insightful posts, they have been very educational. I have a question regarding the 'duration' parameter. Have you ever tried setting it to a shorter value than what you currently have, and made a submission?</p>\n<p>I am currently trying to shorten the 'duration', but I keep encountering a 'Submission Scoring Error'. If you have any knowledge on this issue, could you please advise me on how to resolve it?</p>\n<p>Thank you in advance.</p>",
      "rawMarkdown": "Thank you for your insightful posts, they have been very educational. I have a question regarding the 'duration' parameter. Have you ever tried setting it to a shorter value than what you currently have, and made a submission?\n\nI am currently trying to shorten the 'duration', but I keep encountering a 'Submission Scoring Error'. If you have any knowledge on this issue, could you please advise me on how to resolve it?\n\nThank you in advance.",
      "votes": 3,
      "replies": [
        {
          "id": 2538944,
          "postDate": "2023-11-26T14:56:33Z",
          "content": "<p><a href=\"https://www.kaggle.com/yukio0201\" target=\"_blank\">@yukio0201</a> </p>\n<p>Even if the \"duration\" is small, it should still be possible to run.<br>\nThe following commands infer for train.<br>\nYou can use it for debugging.</p>\n<pre><code>rye  python run/inference.py =train\n</code></pre>",
          "rawMarkdown": "@yukio0201 \n\nEven if the \"duration\" is small, it should still be possible to run.\nThe following commands infer for train.\nYou can use it for debugging.\n\n```\nrye run python run/inference.py phase=train\n```",
          "votes": 3
        },
        {
          "id": 2539308,
          "postDate": "2023-11-27T00:26:27.953Z",
          "content": "<p>Because you reduced the distance back then, you will achieve more results. The scoring system will limit the number of results input for each ID, and if exceeded, an error will be reported. You can increase the threshold while reducing the distance</p>",
          "rawMarkdown": "Because you reduced the distance back then, you will achieve more results. The scoring system will limit the number of results input for each ID, and if exceeded, an error will be reported. You can increase the threshold while reducing the distance",
          "votes": 5,
          "replies": [
            {
              "id": 2539652,
              "postDate": "2023-11-27T08:36:48.653Z",
              "content": "<p>How did you confirm that?</p>",
              "rawMarkdown": "How did you confirm that?",
              "votes": 1
            },
            {
              "id": 2547273,
              "postDate": "2023-12-03T11:15:23.347Z",
              "rawMarkdown": "",
              "isDeleted": true
            },
            {
              "id": 2547276,
              "postDate": "2023-12-03T11:16:53.547Z",
              "content": "<p>I took the wrong sub and just changed the threshold for getting the step in the sub to get the score</p>",
              "rawMarkdown": "I took the wrong sub and just changed the threshold for getting the step in the sub to get the score",
              "votes": 1
            }
          ]
        }
      ]
    },
    {
      "id": 2513614,
      "postDate": "2023-11-05T15:08:29.703Z",
      "content": "<p>That's a way to make your life harder by revealing the secrets of your solution.</p>\n<p>Hope you have more tricks and time to get into the top 6. (:</p>\n<p>By the way, do you know how to do the ModelCheckpoint in lightning with a metric computed in on_validation_epoch_end?</p>",
      "rawMarkdown": "That's a way to make your life harder by revealing the secrets of your solution.\n\nHope you have more tricks and time to get into the top 6. (:\n\nBy the way, do you know how to do the ModelCheckpoint in lightning with a metric computed in on_validation_epoch_end?",
      "votes": 3,
      "replies": [
        {
          "id": 2513680,
          "postDate": "2023-11-05T16:04:48.507Z",
          "content": "<p>Saving the best weights based on the evaluation index of the competition can be done with the following code.</p>\n<p><code>rye run python run/train.py monitor=val_score monitor_mode=max</code></p>",
          "rawMarkdown": "Saving the best weights based on the evaluation index of the competition can be done with the following code.\n\n`rye run python run/train.py monitor=val_score monitor_mode=max`",
          "replies": [
            {
              "id": 2513751,
              "postDate": "2023-11-05T17:16:56.090Z",
              "content": "<p>I meant in general not in your specific code.</p>\n<p>When I compute the mAP in on_validation_epoch_end and log it, somehow ModelCheckpoint does not see the mAP to monitor it.</p>",
              "rawMarkdown": "I meant in general not in your specific code.\n\nWhen I compute the mAP in on_validation_epoch_end and log it, somehow ModelCheckpoint does not see the mAP to monitor it.",
              "votes": -2
            },
            {
              "id": 2514124,
              "postDate": "2023-11-06T04:31:40.150Z",
              "rawMarkdown": "",
              "votes": -2,
              "isDeleted": true
            },
            {
              "id": 2514423,
              "postDate": "2023-11-06T09:34:56.900Z",
              "content": "<p>Is this issue the one you encountered? <a href=\"https://github.com/Lightning-AI/lightning/issues/17131\" target=\"_blank\">https://github.com/Lightning-AI/lightning/issues/17131</a></p>",
              "rawMarkdown": "Is this issue the one you encountered? https://github.com/Lightning-AI/lightning/issues/17131",
              "votes": 2
            },
            {
              "id": 2514581,
              "postDate": "2023-11-06T11:53:27.960Z",
              "content": "<p>Chatgpt doesn't know about it.</p>\n<p>Thank you for the link, <a href=\"https://www.kaggle.com/atamazian\" target=\"_blank\">@atamazian</a>. It looks relevant to my problem because I'm using v2.0.</p>",
              "rawMarkdown": "Chatgpt doesn't know about it.\n\nThank you for the link, @atamazian. It looks relevant to my problem because I'm using v2.0.",
              "votes": -1
            }
          ]
        }
      ]
    },
    {
      "id": 2515757,
      "postDate": "2023-11-07T08:02:16.323Z",
      "content": "<p>I am trying to train my own version of the model on kaggle and I am having a bit of difficulty. The scripting commands are not exactly intuitive for this effort. Does anyone know the right sequence to get the command to work? I have this<br>\n <img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14900174%2Fb7b2da20ddeb4f4e8755a2e7c75c2c36%2FCapture.PNG?generation=1699344130927775&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "I am trying to train my own version of the model on kaggle and I am having a bit of difficulty. The scripting commands are not exactly intuitive for this effort. Does anyone know the right sequence to get the command to work? I have this\n ![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14900174%2Fb7b2da20ddeb4f4e8755a2e7c75c2c36%2FCapture.PNG?generation=1699344130927775&alt=media)",
      "votes": 3,
      "replies": [
        {
          "id": 2515834,
          "postDate": "2023-11-07T09:16:14.543Z",
          "content": "<p>The problem is that wandb waits for a user input, which is not possible in Jupyter notebook. I solved this issue by removing wandb logging and switching to local Tensorboard logging.</p>",
          "rawMarkdown": "The problem is that wandb waits for a user input, which is not possible in Jupyter notebook. I solved this issue by removing wandb logging and switching to local Tensorboard logging.",
          "replies": [
            {
              "id": 2515835,
              "postDate": "2023-11-07T09:17:54.363Z",
              "content": "<p>You can change original files within Jupyter notebook by inserting modified code to a single cell with putting <code>%%writefile &lt;filename&gt;</code>  command on top.</p>",
              "rawMarkdown": "You can change original files within Jupyter notebook by inserting modified code to a single cell with putting `%%writefile <filename>`  command on top.",
              "votes": 1
            },
            {
              "id": 2519694,
              "postDate": "2023-11-10T08:58:52.087Z",
              "rawMarkdown": "",
              "isDeleted": true
            }
          ]
        },
        {
          "id": 2516095,
          "postDate": "2023-11-07T13:18:27.713Z",
          "content": "<p>There is a <code>cmd</code> button on Kaggle page, you can run command there.</p>",
          "rawMarkdown": "There is a `cmd` button on Kaggle page, you can run command there.",
          "votes": 1,
          "replies": [
            {
              "id": 2520704,
              "postDate": "2023-11-11T05:24:50.603Z",
              "content": "<p>Where exactly is that? That would help me a lot as I was looking to try a spin-off of this strategy and have been struggling to get the training script to function through several alterations</p>",
              "rawMarkdown": "Where exactly is that? That would help me a lot as I was looking to try a spin-off of this strategy and have been struggling to get the training script to function through several alterations",
              "votes": 1
            },
            {
              "id": 2521358,
              "postDate": "2023-11-11T16:24:05.700Z",
              "content": "<p>Don't know it will help you or not, I haven't try it. It is actually a Console, maybe it is quite different from <code>Terminal</code> or <code>shell</code> on PC.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13000097%2F76e4c6a684664be69815cf3643e3ebe5%2FConsole_kaggle.png?generation=1699719745001624&amp;alt=media\" alt=\"\"></p>",
              "rawMarkdown": "Don't know it will help you or not, I haven't try it. It is actually a Console, maybe it is quite different from `Terminal` or `shell` on PC.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13000097%2F76e4c6a684664be69815cf3643e3ebe5%2FConsole_kaggle.png?generation=1699719745001624&alt=media)",
              "votes": 1
            }
          ]
        },
        {
          "id": 2516658,
          "postDate": "2023-11-07T21:07:49.700Z",
          "content": "<p>Yeah, the code is really interesting, it is a shame  that is in the least readable format available to us. It is a lot of work to even be able to adjust the training for yourself</p>",
          "rawMarkdown": "Yeah, the code is really interesting, it is a shame  that is in the least readable format available to us. It is a lot of work to even be able to adjust the training for yourself",
          "votes": -2
        },
        {
          "id": 2531776,
          "postDate": "2023-11-20T14:17:38.827Z",
          "content": "<p>I'm in the exact same situation. Reading the comments below doesn't help, so if anyone has a cool solution, I'd appreciate it</p>",
          "rawMarkdown": "I'm in the exact same situation. Reading the comments below doesn't help, so if anyone has a cool solution, I'd appreciate it"
        }
      ]
    },
    {
      "id": 2530545,
      "postDate": "2023-11-19T08:35:46.677Z",
      "content": "<p>If you want to make a contribution to this repository, please write a PR or issue summary and link to it in this thread as well to avoid private sharing.</p>\n<hr>\n<p>template</p>\n<h1>[PR or Issue]title</h1>\n<ul>\n<li>summary</li>\n<li>link</li>\n</ul>",
      "rawMarkdown": "If you want to make a contribution to this repository, please write a PR or issue summary and link to it in this thread as well to avoid private sharing.\n\n------\ntemplate\n# [PR or Issue]title\n\n- summary\n- link",
      "votes": 4,
      "replies": [
        {
          "id": 2530553,
          "postDate": "2023-11-19T08:55:10.440Z",
          "content": "<p>My contributions/issues submitted:</p>\n<ul>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/36\" target=\"_blank\">[BUG] Error during the validation</a> (issue)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/38\" target=\"_blank\">Add a license</a> (issue)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/46\" target=\"_blank\">[BUG] CenterNet error</a> (issue)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/52\" target=\"_blank\">Improvement of MLPDecoder</a> (pull request - merged)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/53\" target=\"_blank\">Add ResidualLSTMDecoder</a> (pull request - not merged)</li>\n</ul>",
          "rawMarkdown": "My contributions/issues submitted:\n- [[BUG] Error during the validation](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/36) (issue)\n- [Add a license](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/38) (issue)\n- [[BUG] CenterNet error](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/46) (issue)\n- [Improvement of MLPDecoder](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/52) (pull request - merged)\n- [Add ResidualLSTMDecoder](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/53) (pull request - not merged)",
          "votes": 3
        },
        {
          "id": 2530597,
          "postDate": "2023-11-19T09:51:50.363Z",
          "content": "<h1>Wrong comment fix in spec2Dcnn.</h1>\n<p><a href=\"url\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/30</a><br>\nWhen you intend to modify the model, you may want to note that the annotation of the model output shap in spec2Dcnn is different from that in <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/00ed898b714ab7b8bb747fef87cc1c308d5cacb4/src/models/decoder/unet1ddecoder.py#L213\" target=\"_blank\">unet1ddecoder</a> (with the addition of transpose).</p>",
          "rawMarkdown": "# Wrong comment fix in spec2Dcnn.\n[https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/30](url)\nWhen you intend to modify the model, you may want to note that the annotation of the model output shap in spec2Dcnn is different from that in [unet1ddecoder](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/00ed898b714ab7b8bb747fef87cc1c308d5cacb4/src/models/decoder/unet1ddecoder.py#L213) (with the addition of transpose).\n\n",
          "votes": 3
        },
        {
          "id": 2531150,
          "postDate": "2023-11-20T00:28:14.920Z",
          "content": "<p>My issues submitted:</p>\n<h1>Cannot run run/prepare_data.py</h1>\n<ul>\n<li>summary: The command instructed on the README was wrong</li>\n<li>link: <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/39\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/39</a></li>\n</ul>\n<h1>Running run/prepare_data.py killed</h1>\n<ul>\n<li>summary: It may require &gt; 32 GB RAM</li>\n<li>link: <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/45\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/45</a></li>\n</ul>\n<p>BTW, how could it be private sharing if the GitHub repo's URL has been shared publicly beforehand in Kaggle? I thought any information sharing at an external website that had been shared publicly beforehand in Kaggle was not considered as private sharing.</p>",
          "rawMarkdown": "My issues submitted:\n\n# Cannot run run/prepare_data.py\n- summary: The command instructed on the README was wrong\n- link: https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/39\n\n# Running run/prepare_data.py killed\n- summary: It may require > 32 GB RAM\n- link: https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/45\n\nBTW, how could it be private sharing if the GitHub repo's URL has been shared publicly beforehand in Kaggle? I thought any information sharing at an external website that had been shared publicly beforehand in Kaggle was not considered as private sharing.",
          "votes": 2,
          "replies": [
            {
              "id": 2531517,
              "postDate": "2023-11-20T09:25:33.687Z",
              "content": "<p><a href=\"https://www.kaggle.com/riow1983\" target=\"_blank\">@riow1983</a> <br>\nThank you for your response.</p>\n<p>It may not fall under private sharing, but I think many people don't even look through the issues and PR.<br>\nI asked you to post the content in the thread as well, as I think it is unfair to disadvantage people by not looking at the issues and PRs.</p>",
              "rawMarkdown": "@riow1983 \nThank you for your response.\n\nIt may not fall under private sharing, but I think many people don't even look through the issues and PR.\nI asked you to post the content in the thread as well, as I think it is unfair to disadvantage people by not looking at the issues and PRs.",
              "votes": 3
            }
          ]
        }
      ]
    },
    {
      "id": 2512555,
      "postDate": "2023-11-04T16:30:37.757Z",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>\n<p>Thank you for sharing the code.</p>\n<p>Did you execute the training code using a Kaggle notebook, or did you do it on your local PC? I'd like to try the training you published on Git in a Kaggle notebook, but I'm concerned that it might not be feasible due to GPU and memory issues.</p>",
      "rawMarkdown": "@tubotubo \n\nThank you for sharing the code.\n\nDid you execute the training code using a Kaggle notebook, or did you do it on your local PC? I'd like to try the training you published on Git in a Kaggle notebook, but I'm concerned that it might not be feasible due to GPU and memory issues.",
      "votes": 3,
      "replies": [
        {
          "id": 2513083,
          "postDate": "2023-11-05T07:04:11.407Z",
          "content": "<p>I experimented in a local environment, but this code works in a kaggle environment as well.<br>\nTry running it with dir=kaggle.</p>",
          "rawMarkdown": "I experimented in a local environment, but this code works in a kaggle environment as well.\nTry running it with dir=kaggle.",
          "votes": 3,
          "replies": [
            {
              "id": 2514449,
              "postDate": "2023-11-06T10:02:37.760Z",
              "content": "<p>Or you can change <code>local.yaml</code> content.</p>",
              "rawMarkdown": "Or you can change `local.yaml` content."
            }
          ]
        }
      ]
    },
    {
      "id": 2514036,
      "postDate": "2023-11-06T01:30:40.740Z",
      "content": "<p>I think publishing notebook like this is not good for the people who are serious to join and have score lower than this notebook.</p>",
      "rawMarkdown": "I think publishing notebook like this is not good for the people who are serious to join and have score lower than this notebook.",
      "votes": 4
    },
    {
      "id": 2513035,
      "postDate": "2023-11-05T05:54:29.170Z",
      "content": "<p>I am interested in Gaussian label width (sigma). How width do you set the value?  In your notebook it is set to 10, how many seconds does this correspond to?  In the distributed correct answer label, the number of significant digits is about 1 minute, so it seems more reasonable to look at it with a sigma of about 1 minute.</p>",
      "rawMarkdown": "I am interested in Gaussian label width (sigma). How width do you set the value?  In your notebook it is set to 10, how many seconds does this correspond to?  In the distributed correct answer label, the number of significant digits is about 1 minute, so it seems more reasonable to look at it with a sigma of about 1 minute.",
      "votes": 4,
      "replies": [
        {
          "id": 2513078,
          "postDate": "2023-11-05T07:00:38.667Z",
          "content": "<blockquote>\n  <p>how many seconds does this correspond to?</p>\n</blockquote>\n<p>10 * 5 = 50 [sec]</p>\n<blockquote>\n  <p>I am interested in Gaussian label width (sigma). How width do you set the value?</p>\n</blockquote>\n<p>Good point.<br>\nI am training the model using a sigma that I set up at the beginning.</p>\n<p>However, this sigma is very important.<br>\nBy setting the sigma and duration properly, the accuracy (local cv) can be improved by about 0.01-0.02.</p>\n<p>The following command can be used for grid search, so try it.<br>\n<code>rye run python run/train.py -m duration=100,1000,10000 sigma=5,10,15,20</code></p>",
          "rawMarkdown": "> how many seconds does this correspond to?\n\n10 * 5 = 50 [sec]\n\n> I am interested in Gaussian label width (sigma). How width do you set the value?\n\nGood point.\nI am training the model using a sigma that I set up at the beginning.\n\nHowever, this sigma is very important.\nBy setting the sigma and duration properly, the accuracy (local cv) can be improved by about 0.01-0.02.\n\nThe following command can be used for grid search, so try it.\n`rye run python run/train.py -m duration=100,1000,10000 sigma=5,10,15,20`",
          "votes": 12,
          "replies": [
            {
              "id": 2522960,
              "postDate": "2023-11-13T07:02:02.070Z",
              "content": "<p>Shall we define sigma value only as command line parameter?<br>\nI did not find it in any *.py aor *.yaml file.</p>",
              "rawMarkdown": "Shall we define sigma value only as command line parameter?\nI did not find it in any *.py aor *.yaml file."
            },
            {
              "id": 2522981,
              "postDate": "2023-11-13T07:08:25.310Z",
              "content": "<p><a href=\"https://www.kaggle.com/kaggledummie007\" target=\"_blank\">@kaggledummie007</a> </p>\n<p>The default parameters are written under run/conf/.<br>\nsigma is set in run/conf/dataset/seg.yaml.<br>\nConfig is specified in src/conf.py.</p>",
              "rawMarkdown": "@kaggledummie007 \n\nThe default parameters are written under run/conf/.\nsigma is set in run/conf/dataset/seg.yaml.\nConfig is specified in src/conf.py.",
              "votes": 2
            },
            {
              "id": 2522986,
              "postDate": "2023-11-13T07:11:21.570Z",
              "content": "<p>thank you very much! ))</p>",
              "rawMarkdown": "thank you very much! ))"
            },
            {
              "id": 2526825,
              "postDate": "2023-11-16T04:41:05.570Z",
              "content": "<p>what is the best criteria at experiments or grid search?<br>\nminimum val_loss or maximum val_score?</p>",
              "rawMarkdown": "what is the best criteria at experiments or grid search?\nminimum val_loss or maximum val_score?"
            },
            {
              "id": 2527121,
              "postDate": "2023-11-16T10:06:48.143Z",
              "content": "<p>Better to evaluate with val_score</p>",
              "rawMarkdown": "Better to evaluate with val_score"
            }
          ]
        }
      ]
    },
    {
      "id": 2518901,
      "postDate": "2023-11-09T15:43:17.463Z",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> if you are working with architectures like UNet please take a look about usage the links between the same levels of encoder and decoder (the left and right parts of UNet) - this usually helps to increase the score for such a kind of models</p>",
      "rawMarkdown": "@tubotubo if you are working with architectures like UNet please take a look about usage the links between the same levels of encoder and decoder (the left and right parts of UNet) - this usually helps to increase the score for such a kind of models",
      "votes": 3,
      "replies": [
        {
          "id": 2519620,
          "postDate": "2023-11-10T07:46:47.703Z",
          "content": "<p>I think he already has skip connection in his code.  What else can we try</p>",
          "rawMarkdown": "I think he already has skip connection in his code.  What else can we try",
          "replies": [
            {
              "id": 2520686,
              "postDate": "2023-11-11T04:54:22.047Z",
              "content": "<p>It seems like he's talking about the seqence length.</p>",
              "rawMarkdown": "It seems like he's talking about the seqence length."
            }
          ]
        }
      ]
    },
    {
      "id": 2514077,
      "postDate": "2023-11-06T02:43:31.800Z",
      "content": "<p>I don't think it's a selfish behavior. Deciding to withdraw oneself but not withdraw models that one has created so far letting them be available to the public is understandable. The more the models are adopted by other participants, the more the models are getting seminal. That's another way of participating in a kaggle competition to the end in a busy period.</p>",
      "rawMarkdown": "I don't think it's a selfish behavior. Deciding to withdraw oneself but not withdraw models that one has created so far letting them be available to the public is understandable. The more the models are adopted by other participants, the more the models are getting seminal. That's another way of participating in a kaggle competition to the end in a busy period.",
      "votes": 2,
      "replies": [
        {
          "id": 2515671,
          "postDate": "2023-11-07T05:25:36.597Z",
          "content": "<p>Totally agree, the goal is to train the best model possible, maybe a lot of people will fine tune this model and get even higher scores then the top5, which would be amazing. This would probably make the competition hosts happy too. </p>",
          "rawMarkdown": "Totally agree, the goal is to train the best model possible, maybe a lot of people will fine tune this model and get even higher scores then the top5, which would be amazing. This would probably make the competition hosts happy too. ",
          "votes": -5
        }
      ]
    },
    {
      "id": 2560628,
      "postDate": "2023-12-13T20:35:02.843Z",
      "content": "<p>Wow!!! Thanks for this! So my thinking of using spectrograms was not a bad one. This is encouraging. Thanks again.</p>",
      "rawMarkdown": "Wow!!! Thanks for this! So my thinking of using spectrograms was not a bad one. This is encouraging. Thanks again.",
      "votes": 1
    },
    {
      "id": 2546713,
      "postDate": "2023-12-02T18:23:17.787Z",
      "content": "<p>I am wondering where the idea for this architecture comes from. The Unet is by itself an encoder/decoder architecture, and the encoder is a feature extractor. But instead of just using a single unet (1d) as both encoder and feature extractor, you also first extract features using multiple kernel sizes. Then you decode the 2d output into 1d using a separate unet style model. Why not just use a single 1d unet?</p>\n<p>I'm curious what the 2d heatmap represents. Since this is a 1d problem, why is representing the data as 2d a good idea?</p>",
      "rawMarkdown": "I am wondering where the idea for this architecture comes from. The Unet is by itself an encoder/decoder architecture, and the encoder is a feature extractor. But instead of just using a single unet (1d) as both encoder and feature extractor, you also first extract features using multiple kernel sizes. Then you decode the 2d output into 1d using a separate unet style model. Why not just use a single 1d unet?\n\nI'm curious what the 2d heatmap represents. Since this is a 1d problem, why is representing the data as 2d a good idea?",
      "votes": 1,
      "replies": [
        {
          "id": 2547056,
          "postDate": "2023-12-03T06:08:58.140Z",
          "content": "<ol>\n<li>image recognition model (2D) has been studied extensively</li>\n<li>converting to spectrogram can get frequency information</li>\n</ol>",
          "rawMarkdown": "1. image recognition model (2D) has been studied extensively\n2. converting to spectrogram can get frequency information",
          "votes": 2
        }
      ]
    },
    {
      "id": 2545528,
      "postDate": "2023-12-01T14:43:35.967Z",
      "content": "<p>Why is hour converted to degrees using </p>\n<pre><code>def to_coord(x: pl.Expr, max_: int, : ) -&gt; [pl.Expr]:\n     =  * np. * (x % max_) / max_\n    x_sin = .()\n    x_cos = .()\n\n    return [x_sin.alias(f), x_cos.alias(f)]\n</code></pre>\n<p>and how important is that? Why not just convert to the range [0, 1] ?</p>\n<p>It looks like it makes it smoother. Instead of a sharp peak from 23 to 0, it is smoother.</p>\n<p>Why are both <code>hour_sin</code> and <code>hour_cos</code> used? Isn't 1 enough?</p>",
      "rawMarkdown": "Why is hour converted to degrees using \n\n```\ndef to_coord(x: pl.Expr, max_: int, name: str) -> list[pl.Expr]:\n    rad = 2 * np.pi * (x % max_) / max_\n    x_sin = rad.sin()\n    x_cos = rad.cos()\n\n    return [x_sin.alias(f\"{name}_sin\"), x_cos.alias(f\"{name}_cos\")]\n```\n\nand how important is that? Why not just convert to the range [0, 1] ?\n\nIt looks like it makes it smoother. Instead of a sharp peak from 23 to 0, it is smoother.\n\nWhy are both `hour_sin` and `hour_cos` used? Isn't 1 enough?",
      "votes": 1,
      "replies": [
        {
          "id": 2546949,
          "postDate": "2023-12-03T03:35:44.967Z",
          "content": "<p>When using only the sine function to represent a 24-hour cycle, there is an overlap in the values for AM and PM times, which can lead to ambiguity.</p>",
          "rawMarkdown": "When using only the sine function to represent a 24-hour cycle, there is an overlap in the values for AM and PM times, which can lead to ambiguity.",
          "replies": [
            {
              "id": 2547611,
              "postDate": "2023-12-03T16:41:29.373Z",
              "content": "<p>Thanks. I found <a href=\"https://ianlondon.github.io/blog/encoding-cyclical-features-24hour-time/\" target=\"_blank\">this article</a> helpful</p>",
              "rawMarkdown": "Thanks. I found [this article](https://ianlondon.github.io/blog/encoding-cyclical-features-24hour-time/) helpful"
            }
          ]
        }
      ]
    },
    {
      "id": 2544143,
      "postDate": "2023-11-30T15:53:40.683Z",
      "content": "<p>Thank you for your project, it's really great and boosted my knowledge a lot! May I ask how do you debug your code if something went wrong? Do you use special tools for that or just use basic things like python debugger or print statements?</p>",
      "rawMarkdown": "Thank you for your project, it's really great and boosted my knowledge a lot! May I ask how do you debug your code if something went wrong? Do you use special tools for that or just use basic things like python debugger or print statements?",
      "votes": 1,
      "replies": [
        {
          "id": 2544321,
          "postDate": "2023-11-30T18:39:47.650Z",
          "content": "<p>I use the \"pdb\" for debugging</p>",
          "rawMarkdown": "I use the \"pdb\" for debugging",
          "votes": 1
        }
      ]
    },
    {
      "id": 2538567,
      "postDate": "2023-11-26T09:13:48.983Z",
      "content": "<p>Did anyone try to run the training script in kaggle and it just crashes the notebook after maybe 20+ epochs?</p>",
      "rawMarkdown": "Did anyone try to run the training script in kaggle and it just crashes the notebook after maybe 20+ epochs?",
      "votes": 1
    },
    {
      "id": 2512326,
      "postDate": "2023-11-04T11:21:17.243Z",
      "content": "<p>Js, you just ruined the competition</p>",
      "rawMarkdown": "Js, you just ruined the competition",
      "votes": -3
    },
    {
      "id": 2547808,
      "postDate": "2023-12-03T21:50:15.383Z",
      "content": "<p>Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels? In theory this would allow for predicting both an onset and wakeup event at the same timestep.</p>\n<p>I'm also wondering about the loss function. You use BCEWithLogitsLoss with no weights. Since onset/wakeup are rare, wouldn't this loss function bias towards the background class?</p>",
      "rawMarkdown": "Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels? In theory this would allow for predicting both an onset and wakeup event at the same timestep.\n\nI'm also wondering about the loss function. You use BCEWithLogitsLoss with no weights. Since onset/wakeup are rare, wouldn't this loss function bias towards the background class?\n\n",
      "votes": 2,
      "replies": [
        {
          "id": 2548219,
          "postDate": "2023-12-04T08:17:47.787Z",
          "content": "<blockquote>\n  <p>Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels?</p>\n</blockquote>\n<p>Yes. There is a possibility of predicting multiple labels in 1step, although the number may be small.</p>\n<blockquote>\n  <p>wouldn't this loss function bias towards the background class?</p>\n</blockquote>\n<p>Since ap depends only on the order of the scores, it does not matter if bg scores higher.</p>",
          "rawMarkdown": "> Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels?\n\nYes. There is a possibility of predicting multiple labels in 1step, although the number may be small.\n\n> wouldn't this loss function bias towards the background class?\n\nSince ap depends only on the order of the scores, it does not matter if bg scores higher.",
          "votes": 2,
          "replies": [
            {
              "id": 2548675,
              "postDate": "2023-12-04T15:46:55.007Z",
              "content": "<p>To clarify, I’m surprised the model is able to learn the signal for onset/wakeup. There are 2880 timesteps, and only ~10/2880 &gt; 0 for onset/wakeup. So I’m surprised the model is able to learn this signal. </p>",
              "rawMarkdown": "To clarify, I’m surprised the model is able to learn the signal for onset/wakeup. There are 2880 timesteps, and only ~10/2880 > 0 for onset/wakeup. So I’m surprised the model is able to learn this signal. ",
              "votes": 2
            }
          ]
        }
      ]
    },
    {
      "id": 2519326,
      "postDate": "2023-11-09T23:09:45.827Z",
      "content": "<p>What is the best way to further tune this? I am thinking either:</p>\n<ol>\n<li>clone the code to my own github repo, then change the code there.</li>\n<li>create a new kaggle notebook, copy the code over from github (but was there a limitation that this was not done like that in the first place?)</li>\n</ol>\n<p>Does anyone know other ways (better ways) to do it?</p>",
      "rawMarkdown": "What is the best way to further tune this? I am thinking either:\n1. clone the code to my own github repo, then change the code there.\n2. create a new kaggle notebook, copy the code over from github (but was there a limitation that this was not done like that in the first place?)\n\nDoes anyone know other ways (better ways) to do it?",
      "votes": 2,
      "replies": [
        {
          "id": 2519332,
          "postDate": "2023-11-09T23:18:40.117Z",
          "content": "<p>Just take the ideas, apply it in your own code. You will benefit more in the long run.<br>\nThe most critical addition in this code to the existing ideas is the use of 3d outputs and the loss function.</p>",
          "rawMarkdown": "Just take the ideas, apply it in your own code. You will benefit more in the long run.\nThe most critical addition in this code to the existing ideas is the use of 3d outputs and the loss function.",
          "votes": 2,
          "replies": [
            {
              "id": 2519470,
              "postDate": "2023-11-10T04:31:05.557Z",
              "content": "<p>Yeah, I think you have a good point here. Thanks</p>",
              "rawMarkdown": "Yeah, I think you have a good point here. Thanks",
              "votes": 1
            },
            {
              "id": 2536185,
              "postDate": "2023-11-24T02:11:28.440Z",
              "content": "<p>Did 2. Because ive got no gpu locally</p>",
              "rawMarkdown": "Did 2. Because ive got no gpu locally"
            }
          ]
        }
      ]
    },
    {
      "id": 2512458,
      "postDate": "2023-11-04T14:36:00.230Z",
      "content": "<p>Thanks for the post <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> , you just saved me a lot of time and submission attempts with your comment about having multiple files in the output directory. Kudos!</p>",
      "rawMarkdown": "Thanks for the post @tubotubo , you just saved me a lot of time and submission attempts with your comment about having multiple files in the output directory. Kudos!",
      "votes": 2
    },
    {
      "id": 2512216,
      "postDate": "2023-11-04T08:40:00.367Z",
      "content": "<p>It's a nice idea to use 2d heatmaps and UNet encoder-decoder scheme. I noticed that you use quite low downsampling (just 2). I was using 12 until now.</p>",
      "rawMarkdown": "It's a nice idea to use 2d heatmaps and UNet encoder-decoder scheme. I noticed that you use quite low downsampling (just 2). I was using 12 until now.",
      "votes": 2
    },
    {
      "id": 2512437,
      "postDate": "2023-11-04T14:16:49.850Z",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> very nice approach. Similar thing, that was discussed on the other thread recently. Could you clarify, in terms of feature extractor, you implemented 4 ways to do this. Do you use only one method at a time in your pipeline? Or do you use them somehow one by one, for example, CNN -&gt; LSTM etc? </p>\n<p>Also, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?</p>",
      "rawMarkdown": "@tubotubo very nice approach. Similar thing, that was discussed on the other thread recently. Could you clarify, in terms of feature extractor, you implemented 4 ways to do this. Do you use only one method at a time in your pipeline? Or do you use them somehow one by one, for example, CNN -> LSTM etc? \n\nAlso, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?",
      "replies": [
        {
          "id": 2512495,
          "postDate": "2023-11-04T15:15:01.557Z",
          "content": "<blockquote>\n  <p>Do you use only one method at a time in your pipeline?</p>\n</blockquote>\n<p>Pipelines use one method at a time.</p>\n<ol>\n<li>feature extractor: CNN</li>\n<li>encoder: UNet</li>\n<li>decoder: UNet1D</li>\n</ol>\n<blockquote>\n  <p>Also, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?</p>\n</blockquote>\n<p>This task is very similar to soud event detection (SED). <br>\nFor this reason, I tried the 2D approach often used in SED.<br>\n<a href=\"https://arxiv.org/abs/2107.05463\" target=\"_blank\">Sound Event Detection: A Tutorial</a></p>",
          "rawMarkdown": "> Do you use only one method at a time in your pipeline?\n\nPipelines use one method at a time.\n1. feature extractor: CNN\n2. encoder: UNet\n3. decoder: UNet1D\n\n> Also, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?\n\nThis task is very similar to soud event detection (SED). \nFor this reason, I tried the 2D approach often used in SED.\n[Sound Event Detection: A Tutorial](https://arxiv.org/abs/2107.05463)",
          "votes": 4,
          "replies": [
            {
              "id": 2512796,
              "postDate": "2023-11-04T20:42:15.503Z",
              "content": "<p>Thank you. I agree, that it looks exactly like SED. Could you also tell, which loss function did you use? I could not find it in your git code. </p>",
              "rawMarkdown": "Thank you. I agree, that it looks exactly like SED. Could you also tell, which loss function did you use? I could not find it in your git code. "
            },
            {
              "id": 2512802,
              "postDate": "2023-11-04T20:58:00.940Z",
              "content": "<p>It uses BCEWithLogitsLoss (it's in the models files, e.g. src/models/spec1D.py)</p>",
              "rawMarkdown": "It uses BCEWithLogitsLoss (it's in the models files, e.g. src/models/spec1D.py)",
              "votes": 2
            }
          ]
        }
      ]
    },
    {
      "id": 2512984,
      "postDate": "2023-11-05T05:01:18.083Z",
      "content": "<p>You ruined the LB in the short term</p>",
      "rawMarkdown": "You ruined the LB in the short term",
      "votes": -3,
      "replies": [
        {
          "id": 2512987,
          "postDate": "2023-11-05T05:03:33.270Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 2512989,
          "postDate": "2023-11-05T05:04:32.403Z",
          "content": "<p>Even among the top 100 individuals, some have only submitted once, is this fair for those who have been involved and innovative from the beginning</p>",
          "rawMarkdown": "Even among the top 100 individuals, some have only submitted once, is this fair for those who have been involved and innovative from the beginning",
          "votes": 1
        }
      ]
    },
    {
      "id": 2512915,
      "postDate": "2023-11-05T02:44:33.097Z",
      "content": "<p>Nice sharings!</p>\n<p>ps: I'd always prefer a one-notebook training and inference version of code for competitions. If it is possible to combine them into one notebook, it would be nice. 😂</p>",
      "rawMarkdown": "Nice sharings!\n\nps: I'd always prefer a one-notebook training and inference version of code for competitions. If it is possible to combine them into one notebook, it would be nice. 😂",
      "votes": -7
    },
    {
      "id": 2544149,
      "postDate": "2023-11-30T16:07:49.420Z",
      "content": "<p>let me ask you a question<br>\nin config files we can find:</p>\n<pre><code>\noptimizer:\n  lr: \n</code></pre>\n<p>and in logger we can see:<br>\nlr-AdamW ████████▇▇▇▇▇▆▆▆▆▅▅▅▄▄▄▄▃▃▃▃▂▂▂▂▂▂▁▁▁▁▁▁</p>\n<p>is the config lr the final value of learning rate or starting value?</p>",
      "rawMarkdown": "let me ask you a question\nin config files we can find:\n```python\n# optimizer\noptimizer:\n  lr: 0.0005\n```\n\nand in logger we can see:\nlr-AdamW ████████▇▇▇▇▇▆▆▆▆▅▅▅▄▄▄▄▃▃▃▃▂▂▂▂▂▂▁▁▁▁▁▁\n\nis the config lr the final value of learning rate or starting value?",
      "replies": [
        {
          "id": 2544322,
          "postDate": "2023-11-30T18:40:52.897Z",
          "content": "<p>Because of the learning rate scheduler, lr varies with each step.</p>",
          "rawMarkdown": "Because of the learning rate scheduler, lr varies with each step.",
          "replies": [
            {
              "id": 2544334,
              "postDate": "2023-11-30T18:47:21.273Z",
              "content": "<p>But at wich epoch do we have lr=0.0005?</p>",
              "rawMarkdown": "But at wich epoch do we have lr=0.0005?"
            },
            {
              "id": 2544339,
              "postDate": "2023-11-30T18:56:30.160Z",
              "content": "<p>lr is 0.0005 at step=0.</p>",
              "rawMarkdown": "lr is 0.0005 at step=0.",
              "votes": 1
            },
            {
              "id": 2545653,
              "postDate": "2023-12-01T16:18:18.840Z",
              "content": "<p>thank you very much!</p>",
              "rawMarkdown": "thank you very much!"
            }
          ]
        },
        {
          "id": 2546851,
          "postDate": "2023-12-02T23:35:32.517Z",
          "content": "<p>Here's how **lr ** changes:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8763601%2F8340060a52a73a6cbc87fd3dfcba52e3%2Flr.PNG?generation=1701560088302844&amp;alt=media\" alt=\"\"></p>",
          "rawMarkdown": "Here's how **lr ** changes:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8763601%2F8340060a52a73a6cbc87fd3dfcba52e3%2Flr.PNG?generation=1701560088302844&alt=media)"
        }
      ]
    },
    {
      "id": 2541783,
      "postDate": "2023-11-28T19:29:48.070Z",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> can some one explain me how you created the fold0.yaml config. is it Group Fold or StratifiedGroupKFold?..is it a 5 fold or 4fold.  how did you do that. could you please explain?</p>",
      "rawMarkdown": "@tubotubo can some one explain me how you created the fold0.yaml config. is it Group Fold or StratifiedGroupKFold?..is it a 5 fold or 4fold.  how did you do that. could you please explain?",
      "replies": [
        {
          "id": 2541993,
          "postDate": "2023-11-29T01:49:52.683Z",
          "content": "<p>It seems that fold_0.yaml puts first 80% of series_ids to train and the last 20% to val. The github repo contains config only for fold_0, but, you can add fold_1.yaml, fold_N.yaml, … and split them as you want.</p>",
          "rawMarkdown": "It seems that fold_0.yaml puts first 80% of series_ids to train and the last 20% to val. The github repo contains config only for fold_0, but, you can add fold_1.yaml, fold_N.yaml, ... and split them as you want.",
          "votes": 3
        }
      ]
    },
    {
      "id": 2530429,
      "postDate": "2023-11-19T06:19:37.363Z",
      "content": "<p>Has anyone encountered the same problem as me? I averaged three 729 models (two with different architectures and one with a slightly tweaked architecture) and the other 72+ models, but the score was still lower than the previous 729 model and several 72+ models. I don’t know if it’s because of the diversity. . .</p>",
      "rawMarkdown": "Has anyone encountered the same problem as me? I averaged three 729 models (two with different architectures and one with a slightly tweaked architecture) and the other 72+ models, but the score was still lower than the previous 729 model and several 72+ models. I don’t know if it’s because of the diversity. . .",
      "replies": [
        {
          "id": 2530472,
          "postDate": "2023-11-19T07:30:28.920Z",
          "content": "<p>You may overfit on the training set.</p>",
          "rawMarkdown": "You may overfit on the training set.",
          "replies": [
            {
              "id": 2530491,
              "postDate": "2023-11-19T07:49:08.283Z",
              "rawMarkdown": "",
              "isDeleted": true
            }
          ]
        }
      ]
    },
    {
      "id": 2528464,
      "postDate": "2023-11-17T11:44:15.900Z",
      "content": "<p>nicework,really helpful</p>",
      "rawMarkdown": "nicework,really helpful"
    },
    {
      "id": 2524468,
      "postDate": "2023-11-14T09:07:50.843Z",
      "content": "<p>May I ask you how long it takes to train a round（just one epoch）, and what kind of environment is it based on (what kind of GPU is used)? It's my first time to participate in this kind of competition, so I don't know if I have successfully run the code.</p>",
      "rawMarkdown": "May I ask you how long it takes to train a round（just one epoch）, and what kind of environment is it based on (what kind of GPU is used)? It's my first time to participate in this kind of competition, so I don't know if I have successfully run the code.",
      "replies": [
        {
          "id": 2524654,
          "postDate": "2023-11-14T12:28:25.050Z",
          "content": "<p>RTX3090 takes about 45min for full train with 50 epochs<br>\nI use wsl2 <a href=\"https://www.kaggle.com/windows11\" target=\"_blank\">@windows11</a></p>",
          "rawMarkdown": "RTX3090 takes about 45min for full train with 50 epochs\nI use wsl2 @windows11",
          "replies": [
            {
              "id": 2524847,
              "postDate": "2023-11-14T15:02:46.233Z",
              "content": "<p>Thank you for the reply</p>",
              "rawMarkdown": "Thank you for the reply"
            }
          ]
        },
        {
          "id": 2525324,
          "postDate": "2023-11-15T03:28:48.060Z",
          "content": "<p>On Colab with T4 (high RAM) it takes about 50 seconds per epoch.</p>",
          "rawMarkdown": "On Colab with T4 (high RAM) it takes about 50 seconds per epoch."
        },
        {
          "id": 2525523,
          "postDate": "2023-11-15T07:04:21.383Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    },
    {
      "id": 2523609,
      "postDate": "2023-11-13T15:44:56.230Z",
      "content": "<p>Nice working and moreover approach, awesome all <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>",
      "rawMarkdown": "Nice working and moreover approach, awesome all @tubotubo "
    },
    {
      "id": 2522477,
      "postDate": "2023-11-12T17:40:59.383Z",
      "content": "<p>I notice that you use 24 workers for your dataloaders. Do you mind me asking what specifications your computer has? I would expect with that many workers your RAM would fill up quickly? Or is there a trick I'm not aware of to avoid that problem?</p>",
      "rawMarkdown": "I notice that you use 24 workers for your dataloaders. Do you mind me asking what specifications your computer has? I would expect with that many workers your RAM would fill up quickly? Or is there a trick I'm not aware of to avoid that problem?",
      "replies": [
        {
          "id": 2522499,
          "postDate": "2023-11-12T17:59:50.420Z",
          "content": "<blockquote>\n  <p>Do you mind me asking what specifications your computer has?</p>\n</blockquote>\n<p>The number of threads on my computer is 24.</p>\n<blockquote>\n  <p>I would expect with that many workers your RAM would fill up quickly? Or is there a trick I'm not aware of to avoid that problem?</p>\n</blockquote>\n<p>num_workers is the number of parallelism and has nothing to do with RAM.<br>\nRAM used depends on batch_size</p>",
          "rawMarkdown": "> Do you mind me asking what specifications your computer has?\n\nThe number of threads on my computer is 24.\n\n> I would expect with that many workers your RAM would fill up quickly? Or is there a trick I'm not aware of to avoid that problem?\n\nnum_workers is the number of parallelism and has nothing to do with RAM.\nRAM used depends on batch_size",
          "votes": 1
        }
      ]
    },
    {
      "id": 2519513,
      "postDate": "2023-11-10T05:39:08.487Z",
      "content": "<p>Greetings and thanks for sharing such a nice solution!</p>\n<p>Answer my question, please.<br>\nHere You wrote that wavwgram is made from 3 features - <code>anglez, enmo and hour</code>.<br>\nBut prepare_data.py file contains code for 8 features:</p>\n<pre><code>FEATURE_NAMES = [\n    ,\n    ,\n    ,\n    ,\n    ,\n    ,\n    ,\n    ,\n]\n</code></pre>\n<p>How should we understand this?</p>\n<p>UPDATE</p>\n<p>I found it:<br>\nGreetings and thanks for sharing such a nice solution!</p>\n<p>Answer my question, please.<br>\nHere You wrote that wavwgram is made from 3 features - <code>anglez, enmo and hour</code>.<br>\nBut prepare_data.py file contains code for 8 features:</p>\n<pre><code>FEATURE_NAMES = [\n    ,\n    ,\n    ,\n    ,\n    ,\n    ,\n    ,\n    ,\n]\n</code></pre>\n<p>How should we understand this?</p>\n<p>UPDATE</p>\n<p>I found it in conf/train.yaml:</p>\n<pre><code>\nfeatures:\n  - \n  - \n  \n  \n  - \n  - \n  \n  \n</code></pre>\n<p>Anyway, it seems to be 4 features :)</p>",
      "rawMarkdown": "Greetings and thanks for sharing such a nice solution!\n\nAnswer my question, please.\nHere You wrote that wavwgram is made from 3 features - `anglez, enmo and hour`.\nBut prepare_data.py file contains code for 8 features:\n```python\nFEATURE_NAMES = [\n    \"anglez\",\n    \"enmo\",\n    \"hour_sin\",\n    \"hour_cos\",\n    \"month_sin\",\n    \"month_cos\",\n    \"minute_sin\",\n    \"minute_cos\",\n]\n```\n\nHow should we understand this?\n\nUPDATE\n\nI found it:\nGreetings and thanks for sharing such a nice solution!\n\nAnswer my question, please.\nHere You wrote that wavwgram is made from 3 features - `anglez, enmo and hour`.\nBut prepare_data.py file contains code for 8 features:\n```python\nFEATURE_NAMES = [\n    \"anglez\",\n    \"enmo\",\n    \"hour_sin\",\n    \"hour_cos\",\n    \"month_sin\",\n    \"month_cos\",\n    \"minute_sin\",\n    \"minute_cos\",\n]\n```\n\nHow should we understand this?\n\nUPDATE\n\nI found it in conf/train.yaml:\n\n```python\n# feature\nfeatures:\n  - \"anglez\"\n  - \"enmo\"\n  # - \"month_sin\"\n  # - \"month_cos\"\n  - \"hour_sin\"\n  - \"hour_cos\"\n  # - \"minute_sin\"\n  # - \"minute_cos\"\n```\n\nAnyway, it seems to be 4 features :)",
      "replies": [
        {
          "id": 2520116,
          "postDate": "2023-11-10T15:29:23.753Z",
          "content": "<p>Sorry, Disscussion is wrong.</p>\n<p>My model uses 4 features: anglez, emmo, hour_sin, hour_cos</p>",
          "rawMarkdown": "Sorry, Disscussion is wrong.\n\nMy model uses 4 features: anglez, emmo, hour_sin, hour_cos",
          "votes": 4
        }
      ]
    },
    {
      "id": 2513057,
      "postDate": "2023-11-05T06:30:37.227Z",
      "content": "<p>Thank you for sharing. Keep up the good work. </p>",
      "rawMarkdown": "Thank you for sharing. Keep up the good work. "
    },
    {
      "id": 2547382,
      "postDate": "2023-12-03T13:03:58.253Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 2547401,
          "postDate": "2023-12-03T13:26:43.210Z",
          "content": "<p>I think the hidden data set is more diverse than the public data set. Maybe you can try changing the original training/validation ratio and model fusion of tubo to enhance robustness.</p>",
          "rawMarkdown": "I think the hidden data set is more diverse than the public data set. Maybe you can try changing the original training/validation ratio and model fusion of tubo to enhance robustness.",
          "replies": [
            {
              "id": 2547405,
              "postDate": "2023-12-03T13:30:49.587Z",
              "rawMarkdown": "",
              "isDeleted": true
            },
            {
              "id": 2547412,
              "postDate": "2023-12-03T13:38:39.140Z",
              "rawMarkdown": "",
              "isDeleted": true
            }
          ]
        }
      ]
    },
    {
      "id": 2537312,
      "postDate": "2023-11-25T03:38:23.210Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 2537741,
          "postDate": "2023-11-25T12:59:48.783Z",
          "content": "<p>He does, in the prepare_data pipeline.</p>",
          "rawMarkdown": "He does, in the prepare_data pipeline.",
          "votes": 1
        }
      ]
    },
    {
      "id": 2531446,
      "postDate": "2023-11-20T08:02:15.757Z",
      "rawMarkdown": "",
      "votes": 5,
      "isDeleted": true,
      "replies": [
        {
          "id": 2531537,
          "postDate": "2023-11-20T09:49:24.973Z",
          "content": "<p><a href=\"https://www.kaggle.com/jonnykimmm\" target=\"_blank\">@jonnykimmm</a> </p>\n<p>Thanks for the compliment on my code. I am very happy.</p>\n<p>First of all, the answer to your question is to create a prototype and then a github repo.</p>\n<p>AI/ML projects (especially kaggle) change a lot. Therefore, I believe you need to prototype first to get a deep understanding of the problem.</p>\n<p>I will use the following process to mature the code.<br>\nI have not studied software engineering, so please read this as an opinion.</p>\n<ol>\n<li>create a prototype</li>\n<li>add options on an ad-hoc basis. (e.g. model_type, task_type, dataset_type, …)</li>\n<li>abstract the parts that can be common among the options.<br>\nIn kaggle, too much abstraction can limit the range of strategies. Therefore, it is important to strike a balance between abstraction and concreteness. This balance is very difficult, but I believe it is also an interesting point.</li>\n<li>back to 2.</li>\n</ol>\n<p>This repo was created as follows.</p>\n<p>1st iteration</p>\n<ol>\n<li>create a 1D model as prototype.</li>\n<li>add a 2D model as an option</li>\n<li>abstract feature_extractor, encoder and decoder common to 1D and 2D models<br>\nThis abstraction is based on <a href=\"https://huggingface.co/docs/transformers/main/en/index\" target=\"_blank\">transformers</a>.</li>\n</ol>\n<p>2nd iteration</p>\n<ol>\n<li>add CenterNet and DETR as options</li>\n<li>Abstraction of CenterNet, DETR, Spec1D, Spec2D with <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/models/base.py\" target=\"_blank\">BaseModel</a> so that input_shape=(n_timestamp, n_channles), output_shape=(n_timestamp, 2), output: event occurrence probability per step<br>\nThis abstraction makes it easy to ensemble models that handle different tasks (segmentation , detection).<br>\n(This may be too abstract…?)</li>\n</ol>\n<p>Thanks for reading to the end.<br>\nI hope you find it useful.</p>",
          "rawMarkdown": "@jonnykimmm \n\nThanks for the compliment on my code. I am very happy.\n\nFirst of all, the answer to your question is to create a prototype and then a github repo.\n\nAI/ML projects (especially kaggle) change a lot. Therefore, I believe you need to prototype first to get a deep understanding of the problem.\n\nI will use the following process to mature the code.\nI have not studied software engineering, so please read this as an opinion.\n\n1. create a prototype\n2. add options on an ad-hoc basis. (e.g. model_type, task_type, dataset_type, ...)\n3. abstract the parts that can be common among the options.\nIn kaggle, too much abstraction can limit the range of strategies. Therefore, it is important to strike a balance between abstraction and concreteness. This balance is very difficult, but I believe it is also an interesting point.\n4. back to 2.\n\nThis repo was created as follows.\n\n1st iteration\n1. create a 1D model as prototype.\n2. add a 2D model as an option\n3. abstract feature_extractor, encoder and decoder common to 1D and 2D models\nThis abstraction is based on [transformers](https://huggingface.co/docs/transformers/main/en/index).\n\n2nd iteration\n\n2. add CenterNet and DETR as options\n3. Abstraction of CenterNet, DETR, Spec1D, Spec2D with [BaseModel](https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/models/base.py) so that input_shape=(n_timestamp, n_channles), output_shape=(n_timestamp, 2), output: event occurrence probability per step\nThis abstraction makes it easy to ensemble models that handle different tasks (segmentation , detection).\n(This may be too abstract...?)\n\nThanks for reading to the end.\nI hope you find it useful.",
          "votes": 15,
          "replies": [
            {
              "id": 2531687,
              "postDate": "2023-11-20T12:35:57.843Z",
              "rawMarkdown": "",
              "votes": 3,
              "isDeleted": true
            }
          ]
        }
      ]
    },
    {
      "id": 2530546,
      "postDate": "2023-11-19T08:39:30.533Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 2530548,
          "postDate": "2023-11-19T08:43:02.727Z",
          "rawMarkdown": "",
          "isDeleted": true,
          "replies": [
            {
              "id": 2530558,
              "postDate": "2023-11-19T08:56:49.677Z",
              "content": "<p>Done, see below.</p>",
              "rawMarkdown": "Done, see below.",
              "votes": 1
            }
          ]
        }
      ]
    },
    {
      "id": 2530425,
      "postDate": "2023-11-19T06:16:22.430Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 2530420,
      "postDate": "2023-11-19T06:13:17.827Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 2526087,
      "postDate": "2023-11-15T15:15:03.637Z",
      "rawMarkdown": "",
      "isDeleted": true
    },
    {
      "id": 2523739,
      "postDate": "2023-11-13T17:35:51.610Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 2523786,
          "postDate": "2023-11-13T18:28:24.923Z",
          "content": "<p>In my environment, learning has been done successfully.<br>\nPlease check your environment</p>",
          "rawMarkdown": "In my environment, learning has been done successfully.\nPlease check your environment"
        }
      ]
    },
    {
      "id": 2516294,
      "postDate": "2023-11-07T15:51:17.703Z",
      "rawMarkdown": "",
      "isDeleted": true,
      "replies": [
        {
          "id": 2516313,
          "postDate": "2023-11-07T16:08:21.150Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    },
    {
      "id": 2513364,
      "postDate": "2023-11-05T11:59:02.960Z",
      "rawMarkdown": "",
      "votes": 2,
      "isDeleted": true
    },
    {
      "id": 2513262,
      "postDate": "2023-11-05T10:32:20.117Z",
      "rawMarkdown": "",
      "votes": 2,
      "isDeleted": true
    },
    {
      "id": 2512888,
      "postDate": "2023-11-05T01:30:49.630Z",
      "rawMarkdown": "",
      "votes": -6,
      "isDeleted": true
    },
    {
      "id": 2512478,
      "postDate": "2023-11-04T14:57:44.937Z",
      "rawMarkdown": "",
      "votes": -9,
      "isDeleted": true,
      "replies": [
        {
          "id": 2512485,
          "postDate": "2023-11-04T15:06:50.317Z",
          "content": "<p>I'm also unsure about this <br>\nWhy don't we <strong>take some time and have a closer look at the code</strong>?   :)</p>",
          "rawMarkdown": "I'm also unsure about this \nWhy don't we **take some time and have a closer look at the code**?   :)",
          "votes": 1
        },
        {
          "id": 2512487,
          "postDate": "2023-11-04T15:07:12.490Z",
          "rawMarkdown": "",
          "votes": -3,
          "isDeleted": true
        }
      ]
    },
    {
      "id": 2512275,
      "postDate": "2023-11-04T10:12:09.223Z",
      "rawMarkdown": "",
      "votes": -2,
      "isDeleted": true
    },
    {
      "id": 2512422,
      "postDate": "2023-11-04T13:59:47.380Z",
      "content": "<p>Thanks for sharing!</p>",
      "rawMarkdown": "Thanks for sharing!"
    },
    {
      "id": 2543292,
      "postDate": "2023-11-30T00:29:34.453Z",
      "content": "<p>Thanks for your sharing</p>",
      "rawMarkdown": "Thanks for your sharing"
    },
    {
      "id": 2534871,
      "postDate": "2023-11-23T00:52:23.577Z",
      "content": "<p>Thanks for your sharing</p>",
      "rawMarkdown": "Thanks for your sharing"
    },
    {
      "id": 2515514,
      "postDate": "2023-11-07T01:59:32.543Z",
      "content": "<p>thanks for sharing! </p>",
      "rawMarkdown": "thanks for sharing! "
    }
  ],
  "comments": [
    {
      "id": 2512328,
      "author_name": "213tubo",
      "author_url": "",
      "post_date": "2023-11-04T11:24:25.490000",
      "content": "<p>I do not believe that publicizing this approach will spoil the efforts of the other participants.<br>\nThere are two reasons.<br>\nThe first is that my approach does not encompass all other approaches. I believe that a better model can be created by combining my approach with your approach.<br>\nThe second is that the code I have published has room for many improvements and I believe there is ample time to make improvements.<br>\nFor these two reasons, I thought it was worth releasing the code and model to the public.</p>\n<p>Temporarily, LB may be full of people who just forked it, but it will be weeded out by those who are serious about experimenting.</p>",
      "votes": 48,
      "replies": [
        {
          "id": 2512971,
          "author_name": "Sadhaklal",
          "author_url": "",
          "post_date": "2023-11-05T04:21:46.723000",
          "content": "<p>I appreciate you sharing your approach. But do I appreciate you publishing the \"CMI-submit\" notebook? I'm not sure.</p>\n<p>Just look at the LB now. So many people have 0.707 score (without putting in any effort).</p>\n<p>Your action will lead to less \"variety of solutions\". People who were working on creative approaches will give up, and focus on replicating your approach. In the end, this will reduce the variety of solutions the community develops for this competition.</p>\n<p>I don't know if this is a good thing or a bad thing.</p>",
          "votes": 7,
          "replies": [
            {
              "id": 2512979,
              "author_name": "DongYK",
              "author_url": "",
              "post_date": "2023-11-05T04:46:56.670000",
              "content": "<p>I think people need to add his approach to their own notebooks. So, solutions are getting more various and progressive.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2512980,
              "author_name": "Sadhaklal",
              "author_url": "",
              "post_date": "2023-11-05T04:51:32.840000",
              "content": "<p>I have no problem with him sharing the approach.</p>\n<p>My concern is about sharing the \"CMI-submit\" notebook.</p>",
              "votes": 3,
              "replies": []
            }
          ]
        },
        {
          "id": 2514892,
          "author_name": "Lamal",
          "author_url": "",
          "post_date": "2023-11-06T15:38:48.740000",
          "content": "<p>Much advovated for your kind sharing <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>",
          "votes": 0,
          "replies": [
            {
              "id": 2522105,
              "author_name": "lhchina",
              "author_url": "",
              "post_date": "2023-11-12T11:48:23.423000",
              "content": "<p>Can you share more informations about post_process.score_th and  post_process.distance? <br>\nAnd Why use this? <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> <br>\nThanks</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2522165,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-12T12:49:13.283000",
              "content": "<p><a href=\"https://www.kaggle.com/lhchina\" target=\"_blank\">@lhchina</a> </p>\n<p>The find_peak function of scipy is used to detect events.<br>\nSee the following page for details<br>\n<a href=\"https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html\" target=\"_blank\">https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html</a><br>\n<a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/utils/post_process.py\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/main/src/utils/post_process.py</a></p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2522877,
              "author_name": "lhchina",
              "author_url": "",
              "post_date": "2023-11-13T06:07:49.673000",
              "content": "<p>In the epochs,the valid_loss decrease,but the valid_score not increase.<br>\nlike this:<br>\nEpoch 0/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:48 • 0:00:00 2.44it/s v_num: 3vs7Epoch 0, global step 119: 'val_loss' reached 0.06178 (best 0.06178), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/checkpoints/epoch=0-step=119.ckpt' as top 1<br>\nSaved best model 0.061714774133353835 -&gt; 0.040320251738368874<br>\nEpoch 1/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.66it/s v_num: 3vs7 val_loss: 0.062 val_score: 0.000 train_loss: 0.244                                                   <br>\nEpoch 1, global step 238: 'val_loss' reached 0.04033 (best 0.04033), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/check<br>\nEpoch 2/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.85it/s v_num: 3vs7 val_loss: 0.040 val_score: 0.000 train_loss :                                                                                 0.175                                                   <br>\nSaved best model 0.040320251738368874 -&gt; 0.03305796951684632<br>\nEpoch 3/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:43 • 0:00:00 2.79it/s v_num: 3vs7 val_loss: 0.043 val_score: 0.000 train_loss:0.172                                                  <br>\nEpoch 3, global step 476: 'val_loss' reached 0.03304 (best 0.03304), saving model to './child-mind-institute-detect-sleep-states/5vzv3vs7/check<br>\nEpoch 4/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:43 • 0:00:00 2.89it/s v_num: 3vs7 val_loss: 0.033 val_score: 0.000 train_loss: 0.170                                                   <br>\nEpoch 5/49 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 119/119 0:00:44 • 0:00:00 2.81it/s v_num: 3vs7 val_loss: 0.034 val_score: 0.000 train_loss:0.166 </p>\n<p>It was fine the first time I ran it, and then this happened</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2522885,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-13T06:16:09.313000",
              "content": "<p><a href=\"https://www.kaggle.com/lhchina\" target=\"_blank\">@lhchina</a> </p>\n<p>Please let me know what commands you have executed</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2522897,
              "author_name": "lhchina",
              "author_url": "",
              "post_date": "2023-11-13T06:26:19.390000",
              "content": "<p>python -m run.train exp_name='exp001' num_workers=2 batch_size=32 duration=5760 downsample_rate=2</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2522901,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-13T06:33:21.183000",
              "content": "<p><a href=\"https://www.kaggle.com/lhchina\" target=\"_blank\">@lhchina</a> </p>\n<p>The learning is going well in my environment.<br>\nPlease try git pull and then run the command again.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2523054,
              "author_name": "lhchina",
              "author_url": "",
              "post_date": "2023-11-13T08:07:36.253000",
              "content": "<p>I'm trying it,maybe I change some code in the modelmodule.py.like this:<br>\nclass PLSleepModel(LightningModule):<br>\n    def <strong>init</strong>(<br>\n        self,<br>\n        cfg: TrainConfig,<br>\n        val_event_df: pl.DataFrame,<br>\n        feature_dim: int,<br>\n        num_classes: int,<br>\n        duration: int,<br>\n    ):<br>\n        super().<strong>init</strong>()<br>\n        self.cfg = cfg<br>\n        self.val_event_df = val_event_df<br>\n        num_timesteps = nearest_valid_size(int(duration * cfg.upsample_rate), cfg.downsample_rate)<br>\n        self.model = get_model(<br>\n            cfg,<br>\n            feature_dim=feature_dim,<br>\n            n_classes=num_classes,<br>\n            num_timesteps=num_timesteps // cfg.downsample_rate,<br>\n        )<br>\n        self.duration = duration<br>\n        self.validation_step_outputs: list = []<br>\n        self.__best_loss = np.inf<br>\n        self.__score = 0</p>\n<pre><code>def forward(\n    self,\n    x: torch.Tensor,\n    labels: Optional[torch.Tensor] = None,\n    do_mixup: bool = ,\n    do_cutmix: bool = ,\n) -&gt; ModelOutput:\n    return self.model(x, labels, do_mixup, do_cutmix)\n\ndef training_step(self, batch, batch_idx):\n    do_mixup = np.random.rand() &lt; self.cfg.aug.mixup_prob\n    do_cutmix = np.random.rand() &lt; self.cfg.aug.cutmix_prob\n    output = self.model(batch[], batch[], do_mixup, do_cutmix)\n\n    self.log(\n        ,\n        output.loss.detach().item(),\n        =,\n        =,\n        =,\n        =,\n    )\n    return output.loss\n\ndef validation_step(self, batch, batch_idx):\n    output = self.model.predict(batch[], self.duration, batch[])\n    self.validation_step_outputs.append(\n        (\n            batch[],\n            output.labels.detach().cpu().numpy(),\n            output.preds.detach().cpu().numpy(),\n            output.loss.detach().item(),\n        )\n    )\n    self.log(\n        ,\n        output.loss.detach().item(),\n        =,\n        =,\n        =,\n        =,\n    )\n\n    return output.loss\n\ndef on_validation_epoch_end(self):\n    keys = []\n     x  self.validation_step_outputs:\n        keys.extend(x[0])\n    labels = np.concatenate([x[1]  x  self.validation_step_outputs])\n    preds = np.concatenate([x[2]  x  self.validation_step_outputs])\n    losses = np.array([x[3]  x  self.validation_step_outputs])\n    loss = losses.mean()\n\n    val_pred_df = post_process_for_seg(\n        =keys,\n        =preds,\n        =self.cfg.pp.score_th,\n        =self.cfg.pp.distance,\n    )\n    score = event_detection_ap(self.val_event_df.to_pandas(), val_pred_df.to_pandas())\n    self.log(, score, =, =, =, =)\n\n     loss &lt; self.__best_loss:\n        #np.save(, np.array(keys))\n        #np.save(, labels)\n        #np.save(, preds)\n        val_pred_df.write_csv()\n        torch.save(self.model.state_dict(), )\n        (f)\n        self.__best_loss = loss\n\n     score &gt; self.__score:\n        torch.save(self.model.state_dict(), )\n        (f)\n        self.__score = score\n\n    self.validation_step_outputs.clear()\n</code></pre>\n<p>But I changed it back, and it still had a problem<br>\nWhen I try git pull and then run the command again.it works OK.why？</p>",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 2525315,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-15T03:10:27.373000",
          "content": "",
          "votes": 1,
          "replies": [
            {
              "id": 2525322,
              "author_name": "Cody_Null",
              "author_url": "",
              "post_date": "2023-11-15T03:21:40.413000",
              "content": "<p>I do think sharing the strategy and showing the potential was helpful but I do wish that the inference notebook was not shared. I think the leaderboard is filled with forks of this inference notebook. I would think that this was still ok if there was a training notebook that would actually work on kaggle so the masses would be able to play and learn from it. I was able to do so but I fear most will not have. </p>",
              "votes": 2,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2530561,
      "author_name": "213tubo",
      "author_url": "",
      "post_date": "2023-11-19T09:04:18.357000",
      "content": "<p>I've implemented a few additional models, so if you're interested, give it a try!</p>\n<h1>Implemented models</h1>\n<p>The model is built with two components: feature_extractor and decoder.</p>\n<p>The feature_extractor and decoder that can be specified are as follows</p>\n<h3>Feature Extractor</h3>\n<ul>\n<li><a href=\"https://github.com/analokmaus/kaggle-g2net-public/tree/main/models1d_pytorch\" target=\"_blank\">CNNSpectrogram</a></li>\n<li>LSTMFeatureExtractor</li>\n<li><a href=\"https://arxiv.org/abs/1912.10211\" target=\"_blank\">PANNsFeatureExtractor</a></li>\n<li>SpecFeatureExtractor</li>\n</ul>\n<h3>Decoder</h3>\n<ul>\n<li>MLPDecoder</li>\n<li>LSTMDecoder</li>\n<li>TransformerDecoder</li>\n<li>TransformerCNNDecoder</li>\n<li><a href=\"https://github.com/bamps53/kaggle-dfl-3rd-place-solution/blob/master/models/cnn_3d.py\" target=\"_blank\">UNet1DDecoder</a></li>\n<li>MLPDecoder</li>\n</ul>\n<h3>Model</h3>\n<ul>\n<li>Spec2DCNN: Segmentation through UNet.</li>\n<li>Spec1D: Segmentation without UNet</li>\n<li>DETR2DCNN: Use UNet to detect sleep as in <a href=\"https://arxiv.org/abs/2005.12872\" target=\"_blank\">DETR</a>. This model is still under development.</li>\n<li>CenterNet: Detect onset and offset, respectively, like <a href=\"https://arxiv.org/abs/1904.07850\" target=\"_blank\">CenterNet</a> using UNet</li>\n<li>TransformerAutoModel: <ul>\n<li>Segmentation using huggingface's <a href=\"https://huggingface.co/transformers/v3.0.2/model_doc/auto.html\" target=\"_blank\">AutoModel</a>. don't use feature_extractor and decoder.</li>\n<li>Since the Internet is not available during inference, it is necessary to create a config dataset and specify the path in the model_name.</li></ul></li>\n</ul>\n<p>The correspondence table between each model and dataset is as follows.</p>\n<table>\n<thead>\n<tr>\n<th>model</th>\n<th>dataset</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Spec1D</td>\n<td>seg</td>\n</tr>\n<tr>\n<td>Spec2DCNN</td>\n<td>seg</td>\n</tr>\n<tr>\n<td>DETR2DCNN</td>\n<td>detr</td>\n</tr>\n<tr>\n<td>CenterNet</td>\n<td>centernet</td>\n</tr>\n<tr>\n<td>TransformerAutoModel</td>\n<td>seg</td>\n</tr>\n</tbody>\n</table>\n<p>The command to train CenterNet with feature_extractor=CNNSpectrogram, decoder=UNet1DDecoder is as follows</p>\n<pre><code>rye run python run/train.py model=CenterNet dataset=centernet feature_extractor=CNNSpectrogram decoder=UNet1DDecoder\n</code></pre>",
      "votes": 18,
      "replies": [
        {
          "id": 2530890,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-19T16:11:19.633000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 2533104,
          "author_name": "Lamal",
          "author_url": "",
          "post_date": "2023-11-21T15:31:32.360000",
          "content": "<p>That's a incredible sharing, appreciate your consistent yet high-quality work !</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 2542049,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-29T03:19:39.230000",
          "content": "",
          "votes": 0,
          "replies": [
            {
              "id": 2542055,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-29T03:29:25.887000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2542056,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-29T03:30:13.360000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2512132,
      "author_name": "Donghui Zhang",
      "author_url": "",
      "post_date": "2023-11-04T07:40:28.203000",
      "content": "<p>I don't know whether I should be happy or sad now</p>",
      "votes": 17,
      "replies": [
        {
          "id": 2512135,
          "author_name": "Catharis",
          "author_url": "",
          "post_date": "2023-11-04T07:47:24.280000",
          "content": "<p>I feel exactly the same, I was working very hardly to climb up the ranks and I just got a top50 submission few hours ago which I was very happy about. Then I find this lol. I just see it as a way to ruin the lb and it's not considerate of people's efforts, I mean it's a top 20 submission with a month until the competition ends?.  But then I had to hop on the train since everyone is going to hop on it now. </p>",
          "votes": 8,
          "replies": [
            {
              "id": 2512186,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-04T08:17:23.507000",
              "content": "",
              "votes": 3,
              "replies": []
            },
            {
              "id": 2512267,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-04T10:05:07.753000",
              "content": "",
              "votes": 14,
              "replies": []
            },
            {
              "id": 2512432,
              "author_name": "Fritz Cremer",
              "author_url": "",
              "post_date": "2023-11-04T14:10:48.743000",
              "content": "<p>100% agree, I think sharing methods and approaches is perfectly fine (up to a certain point in the competition). But what is the point in enabling others to just submit a pre-trained model? At least the people who actually replicate the methods put in <strong>some</strong> effort to do that.</p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2514052,
              "author_name": "Ryosuke Horiuchi",
              "author_url": "",
              "post_date": "2023-11-06T01:58:47.770000",
              "content": "<p>The rule \"Don't share the trained weight that scores high and may ruin the LB after a certain point in a competition\" is very obscure. As you know, in the competition's rule there are no explicit threshold in terms of score, the definition of ruining the LB, and when the certain point starts. If you hate it, you need to choose a competition that has such restrictions in the rule explicitly. (However, in kaggle at this moment, you can find no such competitions, I suppose. ) </p>",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 2525323,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-15T03:24:25.870000",
          "content": "",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2513149,
      "author_name": "Araik Tamazian",
      "author_url": "",
      "post_date": "2023-11-05T08:19:30.167000",
      "content": "<p>If you want to install Rye in a Kaggle notebook, use this command:<br>\n<code>curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION=\"--yes\" bash</code><br>\ninstead of<br>\n<code>curl -sSf https://rye-up.com/get | bash</code></p>\n<p>(see <a href=\"https://github.com/mitsuhiko/rye/issues/246\" target=\"_blank\">https://github.com/mitsuhiko/rye/issues/246</a> for details)</p>",
      "votes": 11,
      "replies": [
        {
          "id": 2514292,
          "author_name": "Araik Tamazian",
          "author_url": "",
          "post_date": "2023-11-06T07:03:59.203000",
          "content": "<p>Another note: if you want to run <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> code in a Kaggle notebook, you should change this line in <code>pyproject.toml</code>:<br>\n<code>url = \"https://download.pytorch.org/whl/cu120\"</code><br>\nto<br>\n<code>url = \"https://download.pytorch.org/whl/cu118\"</code><br>\nsince Kaggle environment currently has CUDA 11.4 installed.</p>",
          "votes": 7,
          "replies": [
            {
              "id": 2519541,
              "author_name": "sdhgkdbvj",
              "author_url": "",
              "post_date": "2023-11-10T06:29:05.023000",
              "content": "<p>In the kaggle,I meet this question in trainning phase，and how to deal with it?<br>\nOriginal Traceback (most recent call last):<br>\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py\", line 308, in _worker_loop<br>\n    data = fetcher.fetch(index)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py\", line 51, in fetch<br>\n    data = [self.dataset[idx] for idx in possibly_batched_index]<br>\n  File \"/opt/conda/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py\", line 51, in <br>\n    data = [self.dataset[idx] for idx in possibly_batched_index]<br>\n  File \"/kaggle/input/cmi-code/cmi-code/src/dataset/seg.py\", line 106, in <strong>getitem</strong><br>\n    label = get_seg_label(this_event_df, num_frames, self.cfg.duration, start, end)<br>\n  File \"/kaggle/input/cmi-code/cmi-code/src/dataset/seg.py\", line 21, in get_seg_label<br>\n    this_event_df = this_event_df.query(\"@start &lt;= wakeup &amp; onset &lt;= <a href=\"https://www.kaggle.com/end\" target=\"_blank\">@end</a>\")<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/frame.py\", line 4440, in query<br>\n    res = self.eval(expr, **kwargs)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/frame.py\", line 4566, in eval<br>\n    return _eval(expr, inplace=inplace, **kwargs)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/eval.py\", line 357, in eval<br>\n    ret = eng_inst.evaluate()<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/engines.py\", line 81, in evaluate<br>\n    res = self._evaluate()<br>\n  File \"/opt/conda/lib/python3.10/site-packages/pandas/core/computation/engines.py\", line 121, in _evaluate<br>\n    return ne.evaluate(s, local_dict=scope)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 943, in evaluate<br>\n    raise e<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 851, in validate<br>\n    _names_cache[expr_key] = getExprNames(ex, context)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 714, in getExprNames<br>\n    ex = stringToExpression(text, {}, context)<br>\n  File \"/opt/conda/lib/python3.10/site-packages/numexpr/necompiler.py\", line 274, in stringToExpression<br>\n    raise ValueError(f'Expression {s} has forbidden control characters.')<br>\nValueError: Expression ((__pd_eval_local_start) &lt;= (wakeup)) &amp; ((onset) &lt;= (__pd_eval_local_end)) has forbidden control characters.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2519984,
              "author_name": "daichi",
              "author_url": "",
              "post_date": "2023-11-10T13:54:27.517000",
              "content": "<p>In the query method of pandas, local variables are referenced in strings using the @ symbol. However, this method can sometimes lead to errors. Instead, consider a method that directly computes and filters data frame conditions.</p>\n<p>The epochs is set to 50, but in my case, the epochs went out of memory at 23. Please let me know if you have any solutions.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2520118,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-10T15:31:02.497000",
              "content": "<p>The version of the code may be different.<br>\nTry git pull to use the latest code.</p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2520130,
              "author_name": "Araik Tamazian",
              "author_url": "",
              "post_date": "2023-11-10T15:43:08.423000",
              "content": "<p>I noticed that you recently had updated the code - it now includes detr2D. Can you specify a source of this architecture?</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2520145,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-10T15:53:24.340000",
              "content": "<p><a href=\"https://www.kaggle.com/atamazian\" target=\"_blank\">@atamazian</a> </p>\n<p>This architecture is called DETR.<br>\nI have implemented it for study purposes, but have not yet achieved good accuracy.</p>\n<p><a href=\"https://arxiv.org/abs/2005.12872\" target=\"_blank\">https://arxiv.org/abs/2005.12872</a></p>",
              "votes": 3,
              "replies": []
            },
            {
              "id": 2520174,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-10T16:19:20.107000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2520759,
              "author_name": "sdhgkdbvj",
              "author_url": "",
              "post_date": "2023-11-11T06:42:15.040000",
              "content": "<p>When I install rye in the kaggle, something wrong. and how to create virtual environment?<br>\n<a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>\n<p>!cp -r /kaggle/input/cmi-code/cmi-code cmi-code <br>\n!pip install hydra-core segmentation_models_pytorch==0.3.3 --no-index --find-links=/kaggle/input/ex-library<br>\n!curl -sSf <a href=\"https://rye-up.com/get\" target=\"_blank\">https://rye-up.com/get</a> | RYE_INSTALL_OPTION=\"--yes\" bash<br>\n!echo 'source \"$HOME/.rye/env\"' &gt;&gt; ~/.bashrc<br>\n!source ~/.bashrc</p>\n<p>This installer will install rye to /root/.rye<br>\nThis path can be changed by exporting the RYE_HOME environment variable.<br>\nDetails:<br>\n  Rye Version: 0.15.2<br>\n  Platform: linux (x86_64)<br>\nInstalled binary to /root/.rye/shims/rye<br>\nBootstrapping rye internals<br>\nDownloading cpython@3.11.6<br>\nChecking checksum██████████████████████████████░░░░ 49.16 MiB/52.29 MiB<br>\nsuccess: Downloaded cpython@3.11.6<br>\nUpgrading pip<br>\nInstalling internal dependencies<br>\nUpdated self-python installation at /root/.rye/self</p>\n<p>The rye directory /root/.rye/shims was not detected on PATH.<br>\nIt is highly recommended that you add it.<br>\nAdd this at the end of your .profile, .zprofile or similar:<br>\n    source \"$HOME/.rye/env\"<br>\nNote: after adding rye to your path, restart your shell for it to take effect.</p>\n<p>!rye sync<br>\n/bin/bash: line 1: rye: command not found</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2520793,
              "author_name": "Araik Tamazian",
              "author_url": "",
              "post_date": "2023-11-11T07:12:29",
              "content": "<p>try <code>!/root/.rye/shims/rye sync</code> instead</p>",
              "votes": 3,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2512169,
      "author_name": "no fit just luck",
      "author_url": "",
      "post_date": "2023-11-04T08:08:51.597000",
      "content": "<p>It's a great share but may not at a right time.</p>",
      "votes": 9,
      "replies": []
    },
    {
      "id": 2514836,
      "author_name": "Bilzard",
      "author_url": "",
      "post_date": "2023-11-06T15:03:16.080000",
      "content": "<p><a href=\"https://www.kaggle.com/tubo\" target=\"_blank\">@tubo</a></p>\n<p>Thank you for sharing gold-standard solution.</p>\n<blockquote>\n  <p>The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.</p>\n</blockquote>\n<p>FYI, about the bisect search part, I rewrite the original logic. Although computation time is not boosted much, I think the logic became simpler and clearer.</p>\n<pre><code> ():\n    \n    \n    idx = bisect_left(gt_times, det_time)\n\n    best_idx = \n    best_error = ()\n\n    range_min = (, idx - )\n    range_max = ((gt_times), idx + )\n     check_idx  (range_min, range_max):  \n         check_idx   excluded_indices:\n            error = (gt_times[check_idx] - det_time)\n             error &lt; best_error:\n                best_error = error\n                best_idx = check_idx\n\n     best_idx, best_error\n</code></pre>",
      "votes": 7,
      "replies": [
        {
          "id": 2514885,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-06T15:32:58.920000",
          "content": "<p>Thanks for the good refactoring!</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 2516831,
          "author_name": "Bilzard",
          "author_url": "",
          "post_date": "2023-11-08T02:24:23.530000",
          "content": "<p>The above code doesn't handle the case if the closest time_step is already matched.<br>\nWe should remove already matched gt indices from list of candidates.</p>\n<p>Since my own prediction code predicts at most 1 event pair per night, it produces the same result, but it should be problematic in general cases.</p>\n<pre><code> ():\n    \n    idx = np.searchsorted(xs, value, side=)\n    best_idx = \n    best_error = ()\n\n    range_min = (, idx - )\n    range_max = ((xs), idx + )\n     check_idx  (\n        range_min, range_max\n    ):  \n        error = (xs[check_idx] - value)\n         error &lt; best_error:\n            best_error = error\n            best_idx = check_idx\n\n     best_idx, best_error\n\n\n ():\n    \n    \n    sorted_gt_times = np.asarray(sorted_gt_times)\n    available_indices = np.asarray(\n        ((((sorted_gt_times))) - excluded_indices), dtype=\n    )\n    sorted_gt_times = sorted_gt_times[available_indices]\n    idx, error = find_nearest(sorted_gt_times, det_time)\n\n     idx  :\n         , ()\n\n     available_indices[idx], error\n</code></pre>",
          "votes": 5,
          "replies": []
        }
      ]
    },
    {
      "id": 2512434,
      "author_name": "Fritz Cremer",
      "author_url": "",
      "post_date": "2023-11-04T14:15:24.720000",
      "content": "<blockquote>\n  <p>I do not believe that publicizing this approach will spoil the efforts of the other participants.</p>\n</blockquote>\n<p>I have to disagree. If you would have just published this post, or maybe even the code, you could maybe argue that. But why publish the weights of a model that scores this high? Especially after there is just one month left. I really don't see the point in that…</p>",
      "votes": 9,
      "replies": [
        {
          "id": 2512469,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-04T14:48:10.367000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 2512489,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-04T15:08:00.163000",
          "content": "<p>Assume that the training code is allowed to be published.</p>\n<p>If the training code is not publicly available, I do not think it is permissible to publish the model weights. If you don't publish the training code, you are not providing any value to the platform.<br>\nHowever, if the training code is to be made public, the weights of the model may or may not be made public.<br>\nAs long as the training code is publicly available, I think you are providing value to the platform.<br>\nI also think there is little difference between just forking the training code and submitting and using the published weights.</p>\n<p>I think this discussion is a difference of ideas, so I will not discuss it further.</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2512548,
              "author_name": "Fritz Cremer",
              "author_url": "",
              "post_date": "2023-11-04T16:20:11.083000",
              "content": "<blockquote>\n  <p>However, if the training code is to be made public, the weights of the model may or may not be made public.</p>\n</blockquote>\n<p>Exactly, but one results in much more \"forkmittings\" than the other. Much fewer people actually go out of their way and train the model and then submit it. And I know that it can be frustrating for someone that put a lot of effort into making a 50th place submission, to be 300th place the next day. That's why I also think you should be careful with publishing training code, especially 1 month before end, which I think is relatively late for the impact it has. I believe a lot of people love the competitive aspect of it, but realistically, that is gone for many people when anything past the top 2% might come from someone who has never touched a machine learning model in their life.</p>\n<p>Also, I wonder why you last submission is one month ago? Couldn't you have published the code back then?</p>",
              "votes": 13,
              "replies": []
            },
            {
              "id": 2512558,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-04T16:35:14.577000",
              "content": "<blockquote>\n  <p>Much fewer people actually go out of their way and train the model and then submit it. </p>\n</blockquote>\n<p>I am skeptical on this point.<br>\nSimply using published weights is difficult to maintain a high ranking. For a time, more people may use the published weights, but I believe that gradually more people will use the weights from the improved model using the training code.</p>\n<blockquote>\n  <p>Also, I wonder why you last submission is one month ago? Couldn't you have published the code back then?</p>\n</blockquote>\n<p>The reason is that a month ago my goal was to win this competition. However, I got busy and decided to withdraw from this competition. Therefore, I decided to publish the code I wrote a month ago.</p>",
              "votes": 2,
              "replies": []
            }
          ]
        },
        {
          "id": 2513068,
          "author_name": "Shiner",
          "author_url": "",
          "post_date": "2023-11-05T06:48:47.603000",
          "content": "<p>Dude, the remained one month is just a start for the competitions. There still a lot people just began their work just now. If you wish to keep your efforts, you should ask hosts to close the \"join button\".</p>",
          "votes": -2,
          "replies": []
        }
      ]
    },
    {
      "id": 2512388,
      "author_name": "213tubo",
      "author_url": "",
      "post_date": "2023-11-04T13:23:18.197000",
      "content": "<p>This is my impression from the experiments I have done, the 2D approach is not that important.<br>\nIt would be more accurate to capture more detailed information in the time direction rather than frequency.<br>\nThis means that the 1D approach may be better than the 2D approach.</p>",
      "votes": 5,
      "replies": [
        {
          "id": 2512497,
          "author_name": "Araik Tamazian",
          "author_url": "",
          "post_date": "2023-11-04T15:15:51.897000",
          "content": "<p>It's hard to say. For example, I'm using 1d approach, but my best result is just LB 0.639 for now.</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2512566,
              "author_name": "yukiya",
              "author_url": "",
              "post_date": "2023-11-04T16:45:12.567000",
              "content": "<p>Look at rank #19 , he's using 1D approach at LB 0.718</p>",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2538861,
      "author_name": "mizoo",
      "author_url": "",
      "post_date": "2023-11-26T14:01:36.833000",
      "content": "<p>Thank you for your insightful posts, they have been very educational. I have a question regarding the 'duration' parameter. Have you ever tried setting it to a shorter value than what you currently have, and made a submission?</p>\n<p>I am currently trying to shorten the 'duration', but I keep encountering a 'Submission Scoring Error'. If you have any knowledge on this issue, could you please advise me on how to resolve it?</p>\n<p>Thank you in advance.</p>",
      "votes": 3,
      "replies": [
        {
          "id": 2538944,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-26T14:56:33",
          "content": "<p><a href=\"https://www.kaggle.com/yukio0201\" target=\"_blank\">@yukio0201</a> </p>\n<p>Even if the \"duration\" is small, it should still be possible to run.<br>\nThe following commands infer for train.<br>\nYou can use it for debugging.</p>\n<pre><code>rye  python run/inference.py =train\n</code></pre>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 2539308,
          "author_name": "wpl",
          "author_url": "",
          "post_date": "2023-11-27T00:26:27.953000",
          "content": "<p>Because you reduced the distance back then, you will achieve more results. The scoring system will limit the number of results input for each ID, and if exceeded, an error will be reported. You can increase the threshold while reducing the distance</p>",
          "votes": 5,
          "replies": [
            {
              "id": 2539652,
              "author_name": "mizoo",
              "author_url": "",
              "post_date": "2023-11-27T08:36:48.653000",
              "content": "<p>How did you confirm that?</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2547273,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-12-03T11:15:23.347000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2547276,
              "author_name": "wpl",
              "author_url": "",
              "post_date": "2023-12-03T11:16:53.547000",
              "content": "<p>I took the wrong sub and just changed the threshold for getting the step in the sub to get the score</p>",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2513614,
      "author_name": "Tolga",
      "author_url": "",
      "post_date": "2023-11-05T15:08:29.703000",
      "content": "<p>That's a way to make your life harder by revealing the secrets of your solution.</p>\n<p>Hope you have more tricks and time to get into the top 6. (:</p>\n<p>By the way, do you know how to do the ModelCheckpoint in lightning with a metric computed in on_validation_epoch_end?</p>",
      "votes": 3,
      "replies": [
        {
          "id": 2513680,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-05T16:04:48.507000",
          "content": "<p>Saving the best weights based on the evaluation index of the competition can be done with the following code.</p>\n<p><code>rye run python run/train.py monitor=val_score monitor_mode=max</code></p>",
          "votes": 0,
          "replies": [
            {
              "id": 2513751,
              "author_name": "Tolga",
              "author_url": "",
              "post_date": "2023-11-05T17:16:56.090000",
              "content": "<p>I meant in general not in your specific code.</p>\n<p>When I compute the mAP in on_validation_epoch_end and log it, somehow ModelCheckpoint does not see the mAP to monitor it.</p>",
              "votes": -2,
              "replies": []
            },
            {
              "id": 2514124,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-06T04:31:40.150000",
              "content": "",
              "votes": -2,
              "replies": []
            },
            {
              "id": 2514423,
              "author_name": "Araik Tamazian",
              "author_url": "",
              "post_date": "2023-11-06T09:34:56.900000",
              "content": "<p>Is this issue the one you encountered? <a href=\"https://github.com/Lightning-AI/lightning/issues/17131\" target=\"_blank\">https://github.com/Lightning-AI/lightning/issues/17131</a></p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2514581,
              "author_name": "Tolga",
              "author_url": "",
              "post_date": "2023-11-06T11:53:27.960000",
              "content": "<p>Chatgpt doesn't know about it.</p>\n<p>Thank you for the link, <a href=\"https://www.kaggle.com/atamazian\" target=\"_blank\">@atamazian</a>. It looks relevant to my problem because I'm using v2.0.</p>",
              "votes": -1,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2515757,
      "author_name": "RyanB23",
      "author_url": "",
      "post_date": "2023-11-07T08:02:16.323000",
      "content": "<p>I am trying to train my own version of the model on kaggle and I am having a bit of difficulty. The scripting commands are not exactly intuitive for this effort. Does anyone know the right sequence to get the command to work? I have this<br>\n <img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14900174%2Fb7b2da20ddeb4f4e8755a2e7c75c2c36%2FCapture.PNG?generation=1699344130927775&amp;alt=media\" alt=\"\"></p>",
      "votes": 3,
      "replies": [
        {
          "id": 2515834,
          "author_name": "Araik Tamazian",
          "author_url": "",
          "post_date": "2023-11-07T09:16:14.543000",
          "content": "<p>The problem is that wandb waits for a user input, which is not possible in Jupyter notebook. I solved this issue by removing wandb logging and switching to local Tensorboard logging.</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2515835,
              "author_name": "Araik Tamazian",
              "author_url": "",
              "post_date": "2023-11-07T09:17:54.363000",
              "content": "<p>You can change original files within Jupyter notebook by inserting modified code to a single cell with putting <code>%%writefile &lt;filename&gt;</code>  command on top.</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2519694,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-10T08:58:52.087000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 2516095,
          "author_name": "Shiner",
          "author_url": "",
          "post_date": "2023-11-07T13:18:27.713000",
          "content": "<p>There is a <code>cmd</code> button on Kaggle page, you can run command there.</p>",
          "votes": 1,
          "replies": [
            {
              "id": 2520704,
              "author_name": "Cody_Null",
              "author_url": "",
              "post_date": "2023-11-11T05:24:50.603000",
              "content": "<p>Where exactly is that? That would help me a lot as I was looking to try a spin-off of this strategy and have been struggling to get the training script to function through several alterations</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2521358,
              "author_name": "Shiner",
              "author_url": "",
              "post_date": "2023-11-11T16:24:05.700000",
              "content": "<p>Don't know it will help you or not, I haven't try it. It is actually a Console, maybe it is quite different from <code>Terminal</code> or <code>shell</code> on PC.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13000097%2F76e4c6a684664be69815cf3643e3ebe5%2FConsole_kaggle.png?generation=1699719745001624&amp;alt=media\" alt=\"\"></p>",
              "votes": 1,
              "replies": []
            }
          ]
        },
        {
          "id": 2516658,
          "author_name": "Fir_las_47",
          "author_url": "",
          "post_date": "2023-11-07T21:07:49.700000",
          "content": "<p>Yeah, the code is really interesting, it is a shame  that is in the least readable format available to us. It is a lot of work to even be able to adjust the training for yourself</p>",
          "votes": -2,
          "replies": []
        },
        {
          "id": 2531776,
          "author_name": "Min Young Joo",
          "author_url": "",
          "post_date": "2023-11-20T14:17:38.827000",
          "content": "<p>I'm in the exact same situation. Reading the comments below doesn't help, so if anyone has a cool solution, I'd appreciate it</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2530545,
      "author_name": "213tubo",
      "author_url": "",
      "post_date": "2023-11-19T08:35:46.677000",
      "content": "<p>If you want to make a contribution to this repository, please write a PR or issue summary and link to it in this thread as well to avoid private sharing.</p>\n<hr>\n<p>template</p>\n<h1>[PR or Issue]title</h1>\n<ul>\n<li>summary</li>\n<li>link</li>\n</ul>",
      "votes": 4,
      "replies": [
        {
          "id": 2530553,
          "author_name": "Araik Tamazian",
          "author_url": "",
          "post_date": "2023-11-19T08:55:10.440000",
          "content": "<p>My contributions/issues submitted:</p>\n<ul>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/36\" target=\"_blank\">[BUG] Error during the validation</a> (issue)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/38\" target=\"_blank\">Add a license</a> (issue)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/46\" target=\"_blank\">[BUG] CenterNet error</a> (issue)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/52\" target=\"_blank\">Improvement of MLPDecoder</a> (pull request - merged)</li>\n<li><a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/53\" target=\"_blank\">Add ResidualLSTMDecoder</a> (pull request - not merged)</li>\n</ul>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 2530597,
          "author_name": "JavaZero",
          "author_url": "",
          "post_date": "2023-11-19T09:51:50.363000",
          "content": "<h1>Wrong comment fix in spec2Dcnn.</h1>\n<p><a href=\"url\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/pull/30</a><br>\nWhen you intend to modify the model, you may want to note that the annotation of the model output shap in spec2Dcnn is different from that in <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/00ed898b714ab7b8bb747fef87cc1c308d5cacb4/src/models/decoder/unet1ddecoder.py#L213\" target=\"_blank\">unet1ddecoder</a> (with the addition of transpose).</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 2531150,
          "author_name": "Ryosuke Horiuchi",
          "author_url": "",
          "post_date": "2023-11-20T00:28:14.920000",
          "content": "<p>My issues submitted:</p>\n<h1>Cannot run run/prepare_data.py</h1>\n<ul>\n<li>summary: The command instructed on the README was wrong</li>\n<li>link: <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/39\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/39</a></li>\n</ul>\n<h1>Running run/prepare_data.py killed</h1>\n<ul>\n<li>summary: It may require &gt; 32 GB RAM</li>\n<li>link: <a href=\"https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/45\" target=\"_blank\">https://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/issues/45</a></li>\n</ul>\n<p>BTW, how could it be private sharing if the GitHub repo's URL has been shared publicly beforehand in Kaggle? I thought any information sharing at an external website that had been shared publicly beforehand in Kaggle was not considered as private sharing.</p>",
          "votes": 2,
          "replies": [
            {
              "id": 2531517,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-20T09:25:33.687000",
              "content": "<p><a href=\"https://www.kaggle.com/riow1983\" target=\"_blank\">@riow1983</a> <br>\nThank you for your response.</p>\n<p>It may not fall under private sharing, but I think many people don't even look through the issues and PR.<br>\nI asked you to post the content in the thread as well, as I think it is unfair to disadvantage people by not looking at the issues and PRs.</p>",
              "votes": 3,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2512555,
      "author_name": "Yohei Tomio",
      "author_url": "",
      "post_date": "2023-11-04T16:30:37.757000",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> </p>\n<p>Thank you for sharing the code.</p>\n<p>Did you execute the training code using a Kaggle notebook, or did you do it on your local PC? I'd like to try the training you published on Git in a Kaggle notebook, but I'm concerned that it might not be feasible due to GPU and memory issues.</p>",
      "votes": 3,
      "replies": [
        {
          "id": 2513083,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-05T07:04:11.407000",
          "content": "<p>I experimented in a local environment, but this code works in a kaggle environment as well.<br>\nTry running it with dir=kaggle.</p>",
          "votes": 3,
          "replies": [
            {
              "id": 2514449,
              "author_name": "Araik Tamazian",
              "author_url": "",
              "post_date": "2023-11-06T10:02:37.760000",
              "content": "<p>Or you can change <code>local.yaml</code> content.</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2514036,
      "author_name": "Mingzheng Shi",
      "author_url": "",
      "post_date": "2023-11-06T01:30:40.740000",
      "content": "<p>I think publishing notebook like this is not good for the people who are serious to join and have score lower than this notebook.</p>",
      "votes": 4,
      "replies": []
    },
    {
      "id": 2513035,
      "author_name": "furu-nag",
      "author_url": "",
      "post_date": "2023-11-05T05:54:29.170000",
      "content": "<p>I am interested in Gaussian label width (sigma). How width do you set the value?  In your notebook it is set to 10, how many seconds does this correspond to?  In the distributed correct answer label, the number of significant digits is about 1 minute, so it seems more reasonable to look at it with a sigma of about 1 minute.</p>",
      "votes": 4,
      "replies": [
        {
          "id": 2513078,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-05T07:00:38.667000",
          "content": "<blockquote>\n  <p>how many seconds does this correspond to?</p>\n</blockquote>\n<p>10 * 5 = 50 [sec]</p>\n<blockquote>\n  <p>I am interested in Gaussian label width (sigma). How width do you set the value?</p>\n</blockquote>\n<p>Good point.<br>\nI am training the model using a sigma that I set up at the beginning.</p>\n<p>However, this sigma is very important.<br>\nBy setting the sigma and duration properly, the accuracy (local cv) can be improved by about 0.01-0.02.</p>\n<p>The following command can be used for grid search, so try it.<br>\n<code>rye run python run/train.py -m duration=100,1000,10000 sigma=5,10,15,20</code></p>",
          "votes": 12,
          "replies": [
            {
              "id": 2522960,
              "author_name": "Oleg Khudyakov",
              "author_url": "",
              "post_date": "2023-11-13T07:02:02.070000",
              "content": "<p>Shall we define sigma value only as command line parameter?<br>\nI did not find it in any *.py aor *.yaml file.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2522981,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-13T07:08:25.310000",
              "content": "<p><a href=\"https://www.kaggle.com/kaggledummie007\" target=\"_blank\">@kaggledummie007</a> </p>\n<p>The default parameters are written under run/conf/.<br>\nsigma is set in run/conf/dataset/seg.yaml.<br>\nConfig is specified in src/conf.py.</p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2522986,
              "author_name": "Oleg Khudyakov",
              "author_url": "",
              "post_date": "2023-11-13T07:11:21.570000",
              "content": "<p>thank you very much! ))</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2526825,
              "author_name": "Oleg Khudyakov",
              "author_url": "",
              "post_date": "2023-11-16T04:41:05.570000",
              "content": "<p>what is the best criteria at experiments or grid search?<br>\nminimum val_loss or maximum val_score?</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2527121,
              "author_name": "213tubo",
              "author_url": "",
              "post_date": "2023-11-16T10:06:48.143000",
              "content": "<p>Better to evaluate with val_score</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2518901,
      "author_name": "Alexander Ryzhkov",
      "author_url": "",
      "post_date": "2023-11-09T15:43:17.463000",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> if you are working with architectures like UNet please take a look about usage the links between the same levels of encoder and decoder (the left and right parts of UNet) - this usually helps to increase the score for such a kind of models</p>",
      "votes": 3,
      "replies": [
        {
          "id": 2519620,
          "author_name": "yukiya",
          "author_url": "",
          "post_date": "2023-11-10T07:46:47.703000",
          "content": "<p>I think he already has skip connection in his code.  What else can we try</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2520686,
              "author_name": "DongYK",
              "author_url": "",
              "post_date": "2023-11-11T04:54:22.047000",
              "content": "<p>It seems like he's talking about the seqence length.</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2514077,
      "author_name": "Ryosuke Horiuchi",
      "author_url": "",
      "post_date": "2023-11-06T02:43:31.800000",
      "content": "<p>I don't think it's a selfish behavior. Deciding to withdraw oneself but not withdraw models that one has created so far letting them be available to the public is understandable. The more the models are adopted by other participants, the more the models are getting seminal. That's another way of participating in a kaggle competition to the end in a busy period.</p>",
      "votes": 2,
      "replies": [
        {
          "id": 2515671,
          "author_name": "n00b",
          "author_url": "",
          "post_date": "2023-11-07T05:25:36.597000",
          "content": "<p>Totally agree, the goal is to train the best model possible, maybe a lot of people will fine tune this model and get even higher scores then the top5, which would be amazing. This would probably make the competition hosts happy too. </p>",
          "votes": -5,
          "replies": []
        }
      ]
    },
    {
      "id": 2560628,
      "author_name": "AIDLRE001",
      "author_url": "",
      "post_date": "2023-12-13T20:35:02.843000",
      "content": "<p>Wow!!! Thanks for this! So my thinking of using spectrograms was not a bad one. This is encouraging. Thanks again.</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2546713,
      "author_name": "cosmosaa",
      "author_url": "",
      "post_date": "2023-12-02T18:23:17.787000",
      "content": "<p>I am wondering where the idea for this architecture comes from. The Unet is by itself an encoder/decoder architecture, and the encoder is a feature extractor. But instead of just using a single unet (1d) as both encoder and feature extractor, you also first extract features using multiple kernel sizes. Then you decode the 2d output into 1d using a separate unet style model. Why not just use a single 1d unet?</p>\n<p>I'm curious what the 2d heatmap represents. Since this is a 1d problem, why is representing the data as 2d a good idea?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2547056,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-12-03T06:08:58.140000",
          "content": "<ol>\n<li>image recognition model (2D) has been studied extensively</li>\n<li>converting to spectrogram can get frequency information</li>\n</ol>",
          "votes": 2,
          "replies": []
        }
      ]
    },
    {
      "id": 2545528,
      "author_name": "cosmosaa",
      "author_url": "",
      "post_date": "2023-12-01T14:43:35.967000",
      "content": "<p>Why is hour converted to degrees using </p>\n<pre><code>def to_coord(x: pl.Expr, max_: int, : ) -&gt; [pl.Expr]:\n     =  * np. * (x % max_) / max_\n    x_sin = .()\n    x_cos = .()\n\n    return [x_sin.alias(f), x_cos.alias(f)]\n</code></pre>\n<p>and how important is that? Why not just convert to the range [0, 1] ?</p>\n<p>It looks like it makes it smoother. Instead of a sharp peak from 23 to 0, it is smoother.</p>\n<p>Why are both <code>hour_sin</code> and <code>hour_cos</code> used? Isn't 1 enough?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2546949,
          "author_name": "n00b",
          "author_url": "",
          "post_date": "2023-12-03T03:35:44.967000",
          "content": "<p>When using only the sine function to represent a 24-hour cycle, there is an overlap in the values for AM and PM times, which can lead to ambiguity.</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2547611,
              "author_name": "cosmosaa",
              "author_url": "",
              "post_date": "2023-12-03T16:41:29.373000",
              "content": "<p>Thanks. I found <a href=\"https://ianlondon.github.io/blog/encoding-cyclical-features-24hour-time/\" target=\"_blank\">this article</a> helpful</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2544143,
      "author_name": "Alex N.",
      "author_url": "",
      "post_date": "2023-11-30T15:53:40.683000",
      "content": "<p>Thank you for your project, it's really great and boosted my knowledge a lot! May I ask how do you debug your code if something went wrong? Do you use special tools for that or just use basic things like python debugger or print statements?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2544321,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-30T18:39:47.650000",
          "content": "<p>I use the \"pdb\" for debugging</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2538567,
      "author_name": "Yutao",
      "author_url": "",
      "post_date": "2023-11-26T09:13:48.983000",
      "content": "<p>Did anyone try to run the training script in kaggle and it just crashes the notebook after maybe 20+ epochs?</p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2512326,
      "author_name": "Pavlo Semchyshyn",
      "author_url": "",
      "post_date": "2023-11-04T11:21:17.243000",
      "content": "<p>Js, you just ruined the competition</p>",
      "votes": -3,
      "replies": []
    },
    {
      "id": 2547808,
      "author_name": "cosmosaa",
      "author_url": "",
      "post_date": "2023-12-03T21:50:15.383000",
      "content": "<p>Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels? In theory this would allow for predicting both an onset and wakeup event at the same timestep.</p>\n<p>I'm also wondering about the loss function. You use BCEWithLogitsLoss with no weights. Since onset/wakeup are rare, wouldn't this loss function bias towards the background class?</p>",
      "votes": 2,
      "replies": [
        {
          "id": 2548219,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-12-04T08:17:47.787000",
          "content": "<blockquote>\n  <p>Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels?</p>\n</blockquote>\n<p>Yes. There is a possibility of predicting multiple labels in 1step, although the number may be small.</p>\n<blockquote>\n  <p>wouldn't this loss function bias towards the background class?</p>\n</blockquote>\n<p>Since ap depends only on the order of the scores, it does not matter if bg scores higher.</p>",
          "votes": 2,
          "replies": [
            {
              "id": 2548675,
              "author_name": "cosmosaa",
              "author_url": "",
              "post_date": "2023-12-04T15:46:55.007000",
              "content": "<p>To clarify, I’m surprised the model is able to learn the signal for onset/wakeup. There are 2880 timesteps, and only ~10/2880 &gt; 0 for onset/wakeup. So I’m surprised the model is able to learn this signal. </p>",
              "votes": 2,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2519326,
      "author_name": "Yutao",
      "author_url": "",
      "post_date": "2023-11-09T23:09:45.827000",
      "content": "<p>What is the best way to further tune this? I am thinking either:</p>\n<ol>\n<li>clone the code to my own github repo, then change the code there.</li>\n<li>create a new kaggle notebook, copy the code over from github (but was there a limitation that this was not done like that in the first place?)</li>\n</ol>\n<p>Does anyone know other ways (better ways) to do it?</p>",
      "votes": 2,
      "replies": [
        {
          "id": 2519332,
          "author_name": "Tolga",
          "author_url": "",
          "post_date": "2023-11-09T23:18:40.117000",
          "content": "<p>Just take the ideas, apply it in your own code. You will benefit more in the long run.<br>\nThe most critical addition in this code to the existing ideas is the use of 3d outputs and the loss function.</p>",
          "votes": 2,
          "replies": [
            {
              "id": 2519470,
              "author_name": "Yutao",
              "author_url": "",
              "post_date": "2023-11-10T04:31:05.557000",
              "content": "<p>Yeah, I think you have a good point here. Thanks</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2536185,
              "author_name": "n00b",
              "author_url": "",
              "post_date": "2023-11-24T02:11:28.440000",
              "content": "<p>Did 2. Because ive got no gpu locally</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2512458,
      "author_name": "Koen van den Brink",
      "author_url": "",
      "post_date": "2023-11-04T14:36:00.230000",
      "content": "<p>Thanks for the post <a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> , you just saved me a lot of time and submission attempts with your comment about having multiple files in the output directory. Kudos!</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2512216,
      "author_name": "Araik Tamazian",
      "author_url": "",
      "post_date": "2023-11-04T08:40:00.367000",
      "content": "<p>It's a nice idea to use 2d heatmaps and UNet encoder-decoder scheme. I noticed that you use quite low downsampling (just 2). I was using 12 until now.</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2512437,
      "author_name": "Man of the year",
      "author_url": "",
      "post_date": "2023-11-04T14:16:49.850000",
      "content": "<p><a href=\"https://www.kaggle.com/tubotubo\" target=\"_blank\">@tubotubo</a> very nice approach. Similar thing, that was discussed on the other thread recently. Could you clarify, in terms of feature extractor, you implemented 4 ways to do this. Do you use only one method at a time in your pipeline? Or do you use them somehow one by one, for example, CNN -&gt; LSTM etc? </p>\n<p>Also, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 2512495,
          "author_name": "213tubo",
          "author_url": "",
          "post_date": "2023-11-04T15:15:01.557000",
          "content": "<blockquote>\n  <p>Do you use only one method at a time in your pipeline?</p>\n</blockquote>\n<p>Pipelines use one method at a time.</p>\n<ol>\n<li>feature extractor: CNN</li>\n<li>encoder: UNet</li>\n<li>decoder: UNet1D</li>\n</ol>\n<blockquote>\n  <p>Also, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?</p>\n</blockquote>\n<p>This task is very similar to soud event detection (SED). <br>\nFor this reason, I tried the 2D approach often used in SED.<br>\n<a href=\"https://arxiv.org/abs/2107.05463\" target=\"_blank\">Sound Event Detection: A Tutorial</a></p>",
          "votes": 4,
          "replies": [
            {
              "id": 2512796,
              "author_name": "Man of the year",
              "author_url": "",
              "post_date": "2023-11-04T20:42:15.503000",
              "content": "<p>Thank you. I agree, that it looks exactly like SED. Could you also tell, which loss function did you use? I could not find it in your git code. </p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2512802,
              "author_name": "chris",
              "author_url": "",
              "post_date": "2023-11-04T20:58:00.940000",
              "content": "<p>It uses BCEWithLogitsLoss (it's in the models files, e.g. src/models/spec1D.py)</p>",
              "votes": 2,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2512984,
      "author_name": "wpl",
      "author_url": "",
      "post_date": "2023-11-05T05:01:18.083000",
      "content": "<p>You ruined the LB in the short term</p>",
      "votes": -3,
      "replies": [
        {
          "id": 2512987,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-05T05:03:33.270000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 2512989,
          "author_name": "wpl",
          "author_url": "",
          "post_date": "2023-11-05T05:04:32.403000",
          "content": "<p>Even among the top 100 individuals, some have only submitted once, is this fair for those who have been involved and innovative from the beginning</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2512915,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-05T02:44:33.097000",
      "content": "",
      "votes": -7,
      "replies": []
    },
    {
      "id": 2544149,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-30T16:07:49.420000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2544322,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-30T18:40:52.897000",
          "content": "",
          "votes": 0,
          "replies": [
            {
              "id": 2544334,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-30T18:47:21.273000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2544339,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-30T18:56:30.160000",
              "content": "",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2545653,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-12-01T16:18:18.840000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 2546851,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-12-02T23:35:32.517000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2541783,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-28T19:29:48.070000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2541993,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-29T01:49:52.683000",
          "content": "",
          "votes": 3,
          "replies": []
        }
      ]
    },
    {
      "id": 2530429,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-19T06:19:37.363000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2530472,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-19T07:30:28.920000",
          "content": "",
          "votes": 0,
          "replies": [
            {
              "id": 2530491,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-19T07:49:08.283000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2528464,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-17T11:44:15.900000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2524468,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-14T09:07:50.843000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2524654,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-14T12:28:25.050000",
          "content": "",
          "votes": 0,
          "replies": [
            {
              "id": 2524847,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-14T15:02:46.233000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 2525324,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-15T03:28:48.060000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 2525523,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-15T07:04:21.383000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2523609,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-13T15:44:56.230000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2522477,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-12T17:40:59.383000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2522499,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-12T17:59:50.420000",
          "content": "",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2519513,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-10T05:39:08.487000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2520116,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-10T15:29:23.753000",
          "content": "",
          "votes": 4,
          "replies": []
        }
      ]
    },
    {
      "id": 2513057,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-05T06:30:37.227000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2547382,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-12-03T13:03:58.253000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2547401,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-12-03T13:26:43.210000",
          "content": "",
          "votes": 0,
          "replies": [
            {
              "id": 2547405,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-12-03T13:30:49.587000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2547412,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-12-03T13:38:39.140000",
              "content": "",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2537312,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-25T03:38:23.210000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2537741,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-25T12:59:48.783000",
          "content": "",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2531446,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-20T08:02:15.757000",
      "content": "",
      "votes": 5,
      "replies": [
        {
          "id": 2531537,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-20T09:49:24.973000",
          "content": "",
          "votes": 15,
          "replies": [
            {
              "id": 2531687,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-20T12:35:57.843000",
              "content": "",
              "votes": 3,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2530546,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-19T08:39:30.533000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2530548,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-19T08:43:02.727000",
          "content": "",
          "votes": 0,
          "replies": [
            {
              "id": 2530558,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-11-19T08:56:49.677000",
              "content": "",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2530425,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-19T06:16:22.430000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2530420,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-19T06:13:17.827000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2526087,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-15T15:15:03.637000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2523739,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-13T17:35:51.610000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2523786,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-13T18:28:24.923000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2516294,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-07T15:51:17.703000",
      "content": "",
      "votes": 0,
      "replies": [
        {
          "id": 2516313,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-07T16:08:21.150000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 2513364,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-05T11:59:02.960000",
      "content": "",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2513262,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-05T10:32:20.117000",
      "content": "",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2512888,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-05T01:30:49.630000",
      "content": "",
      "votes": -6,
      "replies": []
    },
    {
      "id": 2512478,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-04T14:57:44.937000",
      "content": "",
      "votes": -9,
      "replies": [
        {
          "id": 2512485,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-04T15:06:50.317000",
          "content": "",
          "votes": 1,
          "replies": []
        },
        {
          "id": 2512487,
          "author_name": "",
          "author_url": "",
          "post_date": "2023-11-04T15:07:12.490000",
          "content": "",
          "votes": -3,
          "replies": []
        }
      ]
    },
    {
      "id": 2512275,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-04T10:12:09.223000",
      "content": "",
      "votes": -2,
      "replies": []
    },
    {
      "id": 2512422,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-04T13:59:47.380000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2543292,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-30T00:29:34.453000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2534871,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-23T00:52:23.577000",
      "content": "",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2515514,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-11-07T01:59:32.543000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2512088": "I share my approach in this discussion.\n- The code is also available on github\nhttps://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/tree/main\n- submission notebook\nhttps://www.kaggle.com/code/tubotubo/cmi-submit\n\n# Model Structure\nMy model consists of three components: feature extractor, encoder, and decoder.\n\nThe feature extractor takes the raw waveform(anglez, enmo, hour) and creates a wavegram (like an image).\nThe encoder (UNet) takes the wavegrame and creates a two-dimensional heatmap.\ndecoder takes the heatmap and outputs the probability(sleep, onset, wakeup) of an event occurring at each time.\nFinally, post-processing is performed to create a submission file.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Ffa7f5ecfa0f290e1f44e3d2e7dbc4f06%2F(1).jpg?generation=1699079676016847&alt=media)\n\nEach component has the following already implemented.\n\n- feature extractor\n    - CNN\n    - LSTM\n    - Spectrogram\n    - [PANNs](https://arxiv.org/abs/1912.10211)\n- encoder\n    - UNet\n- decoder\n    - UNet1D\n    - LSTM\n    - MLP\n    - Transformer\n\n# Result\nLB: 0.714\nfeature extractor=CNN, encoder=UNet, decoder=UNet1D, downsample_rate=2, seq_len=5760\n\nBecause the code has changed since the last submission, the experiment may not be accurately reproduced with the above settings.\n\n# Tips\n1. The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.\nhttps://github.com/tubo213/kaggle-child-mind-institute-detect-sleep-states/blob/8bbc09aff9c34f12259d536fd496deaade8ec087/src/utils/metrics.py#L179\n2. Outputting a file other than submission.csv and submitting it will result in an error. In the inference notebook, it is better to leave only the final submission.csv.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F6958652%2Fca7e96b19b87610f029c9b42be3b1bea%2FScreenshot%20from%202023-11-04%2016-39-08.png?generation=1699083570125882&alt=media)\n\n# How to contribute\n\nIf you want to make a contribution to this repository, please write a PR or issue summary and link to it in [this thread](https://www.kaggle.com/competitions/child-mind-institute-detect-sleep-states/discussion/452940#2530545) as well to avoid private sharing.",
    "2512328": "I do not believe that publicizing this approach will spoil the efforts of the other participants.\nThere are two reasons.\nThe first is that my approach does not encompass all other approaches. I believe that a better model can be created by combining my approach with your approach.\nThe second is that the code I have published has room for many improvements and I believe there is ample time to make improvements.\nFor these two reasons, I thought it was worth releasing the code and model to the public.\n\nTemporarily, LB may be full of people who just forked it, but it will be weeded out by those who are serious about experimenting.",
    "2530561": "I've implemented a few additional models, so if you're interested, give it a try!\n\n# Implemented models\n\nThe model is built with two components: feature_extractor and decoder.\n\nThe feature_extractor and decoder that can be specified are as follows\n\n### Feature Extractor\n\n- [CNNSpectrogram](https://github.com/analokmaus/kaggle-g2net-public/tree/main/models1d_pytorch)\n- LSTMFeatureExtractor\n- [PANNsFeatureExtractor](https://arxiv.org/abs/1912.10211)\n- SpecFeatureExtractor\n\n### Decoder\n\n- MLPDecoder\n- LSTMDecoder\n- TransformerDecoder\n- TransformerCNNDecoder\n- [UNet1DDecoder](https://github.com/bamps53/kaggle-dfl-3rd-place-solution/blob/master/models/cnn_3d.py)\n- MLPDecoder\n\n### Model\n\n- Spec2DCNN: Segmentation through UNet.\n- Spec1D: Segmentation without UNet\n- DETR2DCNN: Use UNet to detect sleep as in [DETR](https://arxiv.org/abs/2005.12872). This model is still under development.\n- CenterNet: Detect onset and offset, respectively, like [CenterNet](https://arxiv.org/abs/1904.07850) using UNet\n- TransformerAutoModel: \n  - Segmentation using huggingface's [AutoModel](https://huggingface.co/transformers/v3.0.2/model_doc/auto.html). don't use feature_extractor and decoder.\n  -  Since the Internet is not available during inference, it is necessary to create a config dataset and specify the path in the model_name.\n\nThe correspondence table between each model and dataset is as follows.\n\n| model     | dataset   | \n| --------- | --------- | \n| Spec1D    | seg       | \n| Spec2DCNN | seg       | \n| DETR2DCNN | detr      | \n| CenterNet | centernet | \n| TransformerAutoModel | seg |\n\nThe command to train CenterNet with feature_extractor=CNNSpectrogram, decoder=UNet1DDecoder is as follows\n\n```bash\nrye run python run/train.py model=CenterNet dataset=centernet feature_extractor=CNNSpectrogram decoder=UNet1DDecoder\n```",
    "2512132": "I don't know whether I should be happy or sad now",
    "2513149": "If you want to install Rye in a Kaggle notebook, use this command:\n```curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION=\"--yes\" bash```\ninstead of\n```curl -sSf https://rye-up.com/get | bash```\n\n(see https://github.com/mitsuhiko/rye/issues/246 for details)",
    "2512169": "It's a great share but may not at a right time.",
    "2514836": "@tubo\n\nThank you for sharing gold-standard solution.\n\n> The evaluation function can be sped up using a binary search. When the number of detections is large, the evaluation index can be calculated tens to hundreds of times faster than the original implementation.\n\nFYI, about the bisect search part, I rewrite the original logic. Although computation time is not boosted much, I think the logic became simpler and clearer.\n\n```\ndef find_nearest_time_idx(gt_times, det_time, excluded_indices: set):\n    \"\"\"\n    search index of gt_times closest to det_time.\n\n    assumes gt_times is sorted in ascending order.\n    \"\"\"\n    # e.g. if gt_times = [0, 1, 2, 3, 4, 5] and det_time = 2.5, then idx = 3\n    idx = bisect_left(gt_times, det_time)\n\n    best_idx = None\n    best_error = float(\"inf\")\n\n    range_min = max(0, idx - 1)\n    range_max = min(len(gt_times), idx + 2)\n    for check_idx in range(range_min, range_max):  # Check the exact, one before, and one after\n        if check_idx not in excluded_indices:\n            error = abs(gt_times[check_idx] - det_time)\n            if error < best_error:\n                best_error = error\n                best_idx = check_idx\n\n    return best_idx, best_error\n```",
    "2512434": ">I do not believe that publicizing this approach will spoil the efforts of the other participants.\n\nI have to disagree. If you would have just published this post, or maybe even the code, you could maybe argue that. But why publish the weights of a model that scores this high? Especially after there is just one month left. I really don't see the point in that...",
    "2512388": "This is my impression from the experiments I have done, the 2D approach is not that important.\nIt would be more accurate to capture more detailed information in the time direction rather than frequency.\nThis means that the 1D approach may be better than the 2D approach.",
    "2538861": "Thank you for your insightful posts, they have been very educational. I have a question regarding the 'duration' parameter. Have you ever tried setting it to a shorter value than what you currently have, and made a submission?\n\nI am currently trying to shorten the 'duration', but I keep encountering a 'Submission Scoring Error'. If you have any knowledge on this issue, could you please advise me on how to resolve it?\n\nThank you in advance.",
    "2513614": "That's a way to make your life harder by revealing the secrets of your solution.\n\nHope you have more tricks and time to get into the top 6. (:\n\nBy the way, do you know how to do the ModelCheckpoint in lightning with a metric computed in on_validation_epoch_end?",
    "2515757": "I am trying to train my own version of the model on kaggle and I am having a bit of difficulty. The scripting commands are not exactly intuitive for this effort. Does anyone know the right sequence to get the command to work? I have this\n ![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14900174%2Fb7b2da20ddeb4f4e8755a2e7c75c2c36%2FCapture.PNG?generation=1699344130927775&alt=media)",
    "2530545": "If you want to make a contribution to this repository, please write a PR or issue summary and link to it in this thread as well to avoid private sharing.\n\n------\ntemplate\n# [PR or Issue]title\n\n- summary\n- link",
    "2512555": "@tubotubo \n\nThank you for sharing the code.\n\nDid you execute the training code using a Kaggle notebook, or did you do it on your local PC? I'd like to try the training you published on Git in a Kaggle notebook, but I'm concerned that it might not be feasible due to GPU and memory issues.",
    "2514036": "I think publishing notebook like this is not good for the people who are serious to join and have score lower than this notebook.",
    "2513035": "I am interested in Gaussian label width (sigma). How width do you set the value?  In your notebook it is set to 10, how many seconds does this correspond to?  In the distributed correct answer label, the number of significant digits is about 1 minute, so it seems more reasonable to look at it with a sigma of about 1 minute.",
    "2518901": "@tubotubo if you are working with architectures like UNet please take a look about usage the links between the same levels of encoder and decoder (the left and right parts of UNet) - this usually helps to increase the score for such a kind of models",
    "2514077": "I don't think it's a selfish behavior. Deciding to withdraw oneself but not withdraw models that one has created so far letting them be available to the public is understandable. The more the models are adopted by other participants, the more the models are getting seminal. That's another way of participating in a kaggle competition to the end in a busy period.",
    "2560628": "Wow!!! Thanks for this! So my thinking of using spectrograms was not a bad one. This is encouraging. Thanks again.",
    "2546713": "I am wondering where the idea for this architecture comes from. The Unet is by itself an encoder/decoder architecture, and the encoder is a feature extractor. But instead of just using a single unet (1d) as both encoder and feature extractor, you also first extract features using multiple kernel sizes. Then you decode the 2d output into 1d using a separate unet style model. Why not just use a single 1d unet?\n\nI'm curious what the 2d heatmap represents. Since this is a 1d problem, why is representing the data as 2d a good idea?",
    "2545528": "Why is hour converted to degrees using \n\n```\ndef to_coord(x: pl.Expr, max_: int, name: str) -> list[pl.Expr]:\n    rad = 2 * np.pi * (x % max_) / max_\n    x_sin = rad.sin()\n    x_cos = rad.cos()\n\n    return [x_sin.alias(f\"{name}_sin\"), x_cos.alias(f\"{name}_cos\")]\n```\n\nand how important is that? Why not just convert to the range [0, 1] ?\n\nIt looks like it makes it smoother. Instead of a sharp peak from 23 to 0, it is smoother.\n\nWhy are both `hour_sin` and `hour_cos` used? Isn't 1 enough?",
    "2544143": "Thank you for your project, it's really great and boosted my knowledge a lot! May I ask how do you debug your code if something went wrong? Do you use special tools for that or just use basic things like python debugger or print statements?",
    "2538567": "Did anyone try to run the training script in kaggle and it just crashes the notebook after maybe 20+ epochs?",
    "2512326": "Js, you just ruined the competition",
    "2547808": "Just so I'm sure, this is treating the problem as a multi-label problem where for each timestep we predict 0 or more labels? In theory this would allow for predicting both an onset and wakeup event at the same timestep.\n\nI'm also wondering about the loss function. You use BCEWithLogitsLoss with no weights. Since onset/wakeup are rare, wouldn't this loss function bias towards the background class?\n\n",
    "2519326": "What is the best way to further tune this? I am thinking either:\n1. clone the code to my own github repo, then change the code there.\n2. create a new kaggle notebook, copy the code over from github (but was there a limitation that this was not done like that in the first place?)\n\nDoes anyone know other ways (better ways) to do it?",
    "2512458": "Thanks for the post @tubotubo , you just saved me a lot of time and submission attempts with your comment about having multiple files in the output directory. Kudos!",
    "2512216": "It's a nice idea to use 2d heatmaps and UNet encoder-decoder scheme. I noticed that you use quite low downsampling (just 2). I was using 12 until now.",
    "2512437": "@tubotubo very nice approach. Similar thing, that was discussed on the other thread recently. Could you clarify, in terms of feature extractor, you implemented 4 ways to do this. Do you use only one method at a time in your pipeline? Or do you use them somehow one by one, for example, CNN -> LSTM etc? \n\nAlso, any logic or thoughts why Unet encoder was used here? Not the ResNet, for example?",
    "2512984": "You ruined the LB in the short term",
    "2512915": "Nice sharings!\n\nps: I'd always prefer a one-notebook training and inference version of code for competitions. If it is possible to combine them into one notebook, it would be nice. 😂",
    "2544149": "let me ask you a question\nin config files we can find:\n```python\n# optimizer\noptimizer:\n  lr: 0.0005\n```\n\nand in logger we can see:\nlr-AdamW ████████▇▇▇▇▇▆▆▆▆▅▅▅▄▄▄▄▃▃▃▃▂▂▂▂▂▂▁▁▁▁▁▁\n\nis the config lr the final value of learning rate or starting value?",
    "2541783": "@tubotubo can some one explain me how you created the fold0.yaml config. is it Group Fold or StratifiedGroupKFold?..is it a 5 fold or 4fold.  how did you do that. could you please explain?",
    "2530429": "Has anyone encountered the same problem as me? I averaged three 729 models (two with different architectures and one with a slightly tweaked architecture) and the other 72+ models, but the score was still lower than the previous 729 model and several 72+ models. I don’t know if it’s because of the diversity. . .",
    "2528464": "nicework,really helpful",
    "2524468": "May I ask you how long it takes to train a round（just one epoch）, and what kind of environment is it based on (what kind of GPU is used)? It's my first time to participate in this kind of competition, so I don't know if I have successfully run the code.",
    "2523609": "Nice working and moreover approach, awesome all @tubotubo ",
    "2522477": "I notice that you use 24 workers for your dataloaders. Do you mind me asking what specifications your computer has? I would expect with that many workers your RAM would fill up quickly? Or is there a trick I'm not aware of to avoid that problem?",
    "2519513": "Greetings and thanks for sharing such a nice solution!\n\nAnswer my question, please.\nHere You wrote that wavwgram is made from 3 features - `anglez, enmo and hour`.\nBut prepare_data.py file contains code for 8 features:\n```python\nFEATURE_NAMES = [\n    \"anglez\",\n    \"enmo\",\n    \"hour_sin\",\n    \"hour_cos\",\n    \"month_sin\",\n    \"month_cos\",\n    \"minute_sin\",\n    \"minute_cos\",\n]\n```\n\nHow should we understand this?\n\nUPDATE\n\nI found it:\nGreetings and thanks for sharing such a nice solution!\n\nAnswer my question, please.\nHere You wrote that wavwgram is made from 3 features - `anglez, enmo and hour`.\nBut prepare_data.py file contains code for 8 features:\n```python\nFEATURE_NAMES = [\n    \"anglez\",\n    \"enmo\",\n    \"hour_sin\",\n    \"hour_cos\",\n    \"month_sin\",\n    \"month_cos\",\n    \"minute_sin\",\n    \"minute_cos\",\n]\n```\n\nHow should we understand this?\n\nUPDATE\n\nI found it in conf/train.yaml:\n\n```python\n# feature\nfeatures:\n  - \"anglez\"\n  - \"enmo\"\n  # - \"month_sin\"\n  # - \"month_cos\"\n  - \"hour_sin\"\n  - \"hour_cos\"\n  # - \"minute_sin\"\n  # - \"minute_cos\"\n```\n\nAnyway, it seems to be 4 features :)",
    "2513057": "Thank you for sharing. Keep up the good work. ",
    "2547382": "",
    "2537312": "",
    "2531446": "",
    "2530546": "",
    "2530425": "",
    "2530420": "",
    "2526087": "",
    "2523739": "",
    "2516294": "",
    "2513364": "",
    "2513262": "",
    "2512888": "",
    "2512478": "",
    "2512275": "",
    "2512422": "Thanks for sharing!",
    "2543292": "Thanks for your sharing",
    "2534871": "Thanks for your sharing",
    "2515514": "thanks for sharing! "
  }
}