Answers.Body: <p>From what you described, you seem to not be using the time-series capabilities of the LSTM. Try to convert your data into sequences (2D shape to 3D). Something like, [samples, TIME_STEPS, features]. You can also do this with some signal pre-processing like using FFTs on your radio signals as the raw signal interpretation by the LSTM might not produce that much value.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-19T12:15:52.783Z
Answers.Text: Isn't [NumSamples, TimeSteps, Features] exactly what I am doing? NumSamples is the batch-size, TimeStemps is 300 (in my case) and features are the 4 receivers.
Answers.UserDisplayName: binaryBigInt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-19T15:55:07.343Z
Answers.Text: Not really. Right now, you have in one batch 300 data points by 4 channels/receivers (N, 300, 4) whilst with, for example, if you pre-process with an FFT with window size of 30s (assuming random time-frame and frequency) you would end up with something like one batch with (N, 300, 30, 4). See this example: https://towardsdatascience.com/time-series-of-price-anomaly-detection-with-lstm-11a12ba4f6d9
Answers.UserDisplayName: Marco Prata
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-20T07:10:05.600Z
Answers.Text: I am not sure if I can plug a 4D vector into PyTorch's LSTM-Model: https://pytorch.org/docs/stable/generated/torch.nn.LSTM.html
  The input is of size `(N, L, H_in)`.
Answers.UserDisplayName: binaryBigInt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-19T09:51:11.800Z
Answers.LastActivityDate: 2023-07-19T09:51:11.800Z
Answers.UserDisplayName: Marco Prata
Body: <p>I am currently doing my Master's Thesis in the area of wireless sensing using radio waves. I have 4 receiver distributed in the corners of my room and each of them records so called Channel Impulse Responses in the time domain. This is basically a correlation of how the radio wave is influenced by the room and they look like this:</p>
  <p><a href="https://www.researchgate.net/figure/LOS-channel-impulse-response-and-NLOS-channel-impulse-response_fig1_308986067" rel="nofollow noreferrer">https://www.researchgate.net/figure/LOS-channel-impulse-response-and-NLOS-channel-impulse-response_fig1_308986067</a></p>
  <p>Each CIR is 300 samples long in my case and given <span class="math-container">$i, j$</span>, <span class="math-container">$j$</span> is dependent on <span class="math-container">$i$</span> if <span class="math-container">$j\geq i$</span>.</p>
  <p>Thus, the data I feed into my LSTM has the size <code>Nx300x4</code>, where <code>N</code> is the batch size.</p>
  <p>Why I thought LSTM should work here is that the correlation from each sample to the previous samples for each receiver directly relates to the changes happening in the room (not within one single <code>300x4</code> sample but over multiple samples). You can think of the data as 4 sentences with 300 words each.</p>
  <p>The only thing that is a bit confusing here is that the LSTM implementation (at least in PyTorch) returns a vector with size <code>300xhidden</code> for a single input.
  I am reducing the <code>300xhidden</code> vector to the number of classes I have using a flatten + linear layer but I am not sure if this is correct?</p>
  <p>Nonetheless, the LSTM is much worse than my CNN implementation - but why? If I may bring back the analogy to the 4 sentences with 300 words - wasn't LSTM the NN of choice for text analysis before transformer?</p>
  
Tags: <long-short-term-memory>
Title: In theory, LSTM should be adequate to solve my problem, but it doesn't
UserDisplayName: binaryBigInt
ThreadText: # In theory, LSTM should be adequate to solve my problem, but it doesn't
  
  (Asked by: username_0 on 2023-07-18)
  
  I am currently doing my Master's Thesis in the area of wireless sensing using radio waves. I have 4 receiver distributed in the corners of my room and each of them records so called Channel Impulse Responses in the time domain. This is basically a correlation of how the radio wave is influenced by the room and they look like this:
  
  <https://www.researchgate.net/figure/LOS-channel-impulse-response-and-NLOS-channel-impulse-response_fig1_308986067>
  
  Each CIR is 300 samples long in my case and given $i, j$, $j$ is dependent on $i$ if $j\geq i$.
  
  Thus, the data I feed into my LSTM has the size `Nx300x4`, where `N` is the batch size.
  
  Why I thought LSTM should work here is that the correlation from each sample to the previous samples for each receiver directly relates to the changes happening in the room (not within one single `300x4` sample but over multiple samples). You can think of the data as 4 sentences with 300 words each.
  
  The only thing that is a bit confusing here is that the LSTM implementation (at least in PyTorch) returns a vector with size `300xhidden` for a single input.
  I am reducing the `300xhidden` vector to the number of classes I have using a flatten + linear layer but I am not sure if this is correct?
  
  Nonetheless, the LSTM is much worse than my CNN implementation - but why? If I may bring back the analogy to the 4 sentences with 300 words - wasn't LSTM the NN of choice for text analysis before transformer?
  
  **Tags:** long-short-term-memory
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-07-19. Score: 1
  
  From what you described, you seem to not be using the time-series capabilities of the LSTM. Try to convert your data into sequences (2D shape to 3D). Something like, [samples, TIME\_STEPS, features]. You can also do this with some signal pre-processing like using FFTs on your radio signals as the raw signal interpretation by the LSTM might not produce that much value.
  
  > **Comments:**
  > **username_0**: Isn't [NumSamples, TimeSteps, Features] exactly what I am doing? NumSamples is the batch-size, TimeStemps is 300 (in my case) and features are the 4 receivers.  
  > **username_1**: Not really. Right now, you have in one batch 300 data points by 4 channels/receivers (N, 300, 4) whilst with, for example, if you pre-process with an FFT with window size of 30s (assuming random time-frame and frequency) you would end up with something like one batch with (N, 300, 30, 4). See this example: https://towardsdatascience.com/time-series-of-price-anomaly-detection-with-lstm-11a12ba4f6d9  
  > **username_0**: I am not sure if I can plug a 4D vector into PyTorch's LSTM-Model: https://pytorch.org/docs/stable/generated/torch.nn.LSTM.html The input is of size `(N, L, H_in)`.  
  
  ---
  
  