title: How can I split time series into contiguous subsets of fixed length based on categorical values?
body: <p>I have a stacked LSTM network with two time series as input. One of these is categorical with four categories <code>mode = [0,1,2,3]</code>.
  I want to convert this into four LSTM networks with only one input variable.
  The input needs to be split into the categories. All sequences should have the length of <code>lookback</code> and sequences with mixed categories should be skipped.</p>
  <p>For the test I created this sequence generator:</p>
  <pre><code>import numpy as np
  
  # --- create a sequence for testing the algorithm
  N = 40
  
  mode = np.zeros(N)
  mode[0] = np.random.choice([0,1,2,3])
  for i in range(N):
      step = np.random.choice([-1,0,1], p=[0.2,0.6,0.2])
      mode[i] = max(min(mode[i-1]+step,3),0)
  </code></pre>