{
  "id": 442529,
  "title": "Question Regarding 4d LSTM Input.",
  "url": "/competitions/child-mind-institute-detect-sleep-states/discussion/442529",
  "author_name": "Aleksander Klimczyk",
  "post_date": "2023-09-23T04:07:45.319000",
  "votes": 1,
  "comment_count": 6,
  "views": 0,
  "content": "<p>How can I put 4d data into an LSTM? Lets say my data has 30 sequence, 100000-100000 subsequences in each, 20 steps per subsequence, 10 features per step. So (30,100k-200k,20,10). Should I make every sequence its own epoch? Train in steps?</p>",
  "messages": [
    {
      "id": 2452109,
      "postDate": "2023-09-23T05:24:28.383Z",
      "content": "<p>I'm wondering why is it necessary to involve subsequences?</p>\n<p>Generally for time series data, the input for LSTM is 3D: <code>(batch_size, max_seq_len, num_feats)</code></p>",
      "rawMarkdown": "I'm wondering why is it necessary to involve subsequences?\n\nGenerally for time series data, the input for LSTM is 3D: `(batch_size, max_seq_len, num_feats)`",
      "votes": 1,
      "replies": [
        {
          "id": 2453033,
          "postDate": "2023-09-23T18:35:16.503Z",
          "content": "<p>3D input of (batch_size, max_seq_len, num_feats) doesn't make sense to me in this situation because I would only get one output per sequence. With subsequences, I can predict the sleep state at each step of the sequence. The \"awake\" value of every step in a sequence would have a subsequence. I guess I could lump all the subsequences of each sequence together, making it 3d. This leads to a deeper question I have about how to maintain continuity between subsequences. When I pass each subsequence into an LSTM layer, I get an output. But next the subsequence I process will have no connection to the previous. I guess my question really is, is how can I process each subsequence so that the next subsequence will take into account the previous subsequence that was just processed?</p>",
          "rawMarkdown": "3D input of (batch_size, max_seq_len, num_feats) doesn't make sense to me in this situation because I would only get one output per sequence. With subsequences, I can predict the sleep state at each step of the sequence. The \"awake\" value of every step in a sequence would have a subsequence. I guess I could lump all the subsequences of each sequence together, making it 3d. This leads to a deeper question I have about how to maintain continuity between subsequences. When I pass each subsequence into an LSTM layer, I get an output. But next the subsequence I process will have no connection to the previous. I guess my question really is, is how can I process each subsequence so that the next subsequence will take into account the previous subsequence that was just processed?",
          "votes": 1
        },
        {
          "id": 2453057,
          "postDate": "2023-09-23T19:06:45.747Z",
          "content": "<p><a href=\"https://www.kaggle.com/aleksanderklimczyk\" target=\"_blank\">@aleksanderklimczyk</a> CMIIW but if your implementation is in Tensorflow, you can pass a <code>return_sequences=True</code> to the constructor though. By this you get output for each step of the sequence, and avoid \"… I would only get one output per sequence\".</p>",
          "rawMarkdown": "@aleksanderklimczyk CMIIW but if your implementation is in Tensorflow, you can pass a `return_sequences=True` to the constructor though. By this you get output for each step of the sequence, and avoid \"... I would only get one output per sequence\".",
          "votes": 2,
          "replies": [
            {
              "id": 2453172,
              "postDate": "2023-09-23T21:00:52.630Z",
              "rawMarkdown": "",
              "isDeleted": true
            },
            {
              "id": 2453181,
              "postDate": "2023-09-23T21:16:36.807Z",
              "content": "<p>I see. Thank you</p>",
              "rawMarkdown": "I see. Thank you"
            },
            {
              "id": 2453251,
              "postDate": "2023-09-23T22:52:47.963Z",
              "content": "<p>After further reading, I will now try to implement a Bidirectional LSTM.</p>",
              "rawMarkdown": "After further reading, I will now try to implement a Bidirectional LSTM.",
              "votes": 1
            }
          ]
        }
      ]
    },
    {
      "id": 2452049,
      "postDate": "2023-09-23T04:07:45.320Z",
      "content": "<p>How can I put 4d data into an LSTM? Lets say my data has 30 sequence, 100000-100000 subsequences in each, 20 steps per subsequence, 10 features per step. So (30,100k-200k,20,10). Should I make every sequence its own epoch? Train in steps?</p>",
      "rawMarkdown": "How can I put 4d data into an LSTM? Lets say my data has 30 sequence, 100000-100000 subsequences in each, 20 steps per subsequence, 10 features per step. So (30,100k-200k,20,10). Should I make every sequence its own epoch? Train in steps?",
      "votes": 1
    }
  ],
  "comments": [
    {
      "id": 2452109,
      "author_name": "Rimba Erlangga",
      "author_url": "",
      "post_date": "2023-09-23T05:24:28.383000",
      "content": "<p>I'm wondering why is it necessary to involve subsequences?</p>\n<p>Generally for time series data, the input for LSTM is 3D: <code>(batch_size, max_seq_len, num_feats)</code></p>",
      "votes": 1,
      "replies": [
        {
          "id": 2453033,
          "author_name": "Aleksander Klimczyk",
          "author_url": "",
          "post_date": "2023-09-23T18:35:16.503000",
          "content": "<p>3D input of (batch_size, max_seq_len, num_feats) doesn't make sense to me in this situation because I would only get one output per sequence. With subsequences, I can predict the sleep state at each step of the sequence. The \"awake\" value of every step in a sequence would have a subsequence. I guess I could lump all the subsequences of each sequence together, making it 3d. This leads to a deeper question I have about how to maintain continuity between subsequences. When I pass each subsequence into an LSTM layer, I get an output. But next the subsequence I process will have no connection to the previous. I guess my question really is, is how can I process each subsequence so that the next subsequence will take into account the previous subsequence that was just processed?</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 2453057,
          "author_name": "Rimba Erlangga",
          "author_url": "",
          "post_date": "2023-09-23T19:06:45.747000",
          "content": "<p><a href=\"https://www.kaggle.com/aleksanderklimczyk\" target=\"_blank\">@aleksanderklimczyk</a> CMIIW but if your implementation is in Tensorflow, you can pass a <code>return_sequences=True</code> to the constructor though. By this you get output for each step of the sequence, and avoid \"… I would only get one output per sequence\".</p>",
          "votes": 2,
          "replies": [
            {
              "id": 2453172,
              "author_name": "",
              "author_url": "",
              "post_date": "2023-09-23T21:00:52.630000",
              "content": "",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2453181,
              "author_name": "Aleksander Klimczyk",
              "author_url": "",
              "post_date": "2023-09-23T21:16:36.807000",
              "content": "<p>I see. Thank you</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2453251,
              "author_name": "Aleksander Klimczyk",
              "author_url": "",
              "post_date": "2023-09-23T22:52:47.963000",
              "content": "<p>After further reading, I will now try to implement a Bidirectional LSTM.</p>",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2452109": "I'm wondering why is it necessary to involve subsequences?\n\nGenerally for time series data, the input for LSTM is 3D: `(batch_size, max_seq_len, num_feats)`",
    "2452049": "How can I put 4d data into an LSTM? Lets say my data has 30 sequence, 100000-100000 subsequences in each, 20 steps per subsequence, 10 features per step. So (30,100k-200k,20,10). Should I make every sequence its own epoch? Train in steps?"
  }
}