Body: <p>Below is the Python code for making an ensemble model. All the inputs are the same for all three models. But what if the models have different input shapes due to different window size, such as LSTM models. So the input shapes for Model A would be (window_size_A, features) and for Model B would be (window_size_B, features). The window sizes are different but the number of features are the same. As such, due to the different window size, the training data of the same dataset is split differently for each model such that the X_train.shape for model A: (train_data_A, window_size_A, output) And for Model B: (train_data_B, window_size_B, output). Note the training data is from the same dataset but the length is different due to the different window size. How would you make an ensemble of these models?</p>
  <pre><code>def get_model():
      inputs = keras.Input(shape=(128,))
      outputs = layers.Dense(1)(inputs)
      return keras.Model(inputs, outputs)
  
  
  model1 = get_model()
  model2 = get_model()
  model3 = get_model()
  
  inputs = keras.Input(shape=(128,))
  y1 = model1(inputs)
  y2 = model2(inputs)
  y3 = model3(inputs)
  outputs = layers.average([y1, y2, y3])
  ensemble_model = keras.Model(inputs=inputs, outputs=outputs)
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-04T10:39:42.707Z
Comments.Text: So this is a question about implementing ensemble learning in Python?
Comments.UserDisplayName: The Pointer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-04T11:37:41.450Z
Comments.Text: Yes. I guess so. Although any insight in any regard would be welcome and appreciated.
Comments.UserDisplayName: Fruity
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-04T11:48:50.090Z
Comments.Text: Perhaps you could clarify your question and make it more specific? It seems like what you're asking is a bit vague and broad.
Comments.UserDisplayName: The Pointer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-04T12:08:43.183Z
Comments.Text: Sorry about that. I'm new do this. It is about implementing ensemble learning in Python. And about combining two individual lstm models with different window sizes i.e. time steps. This would be that each model can only receive data in a specific shape, a shape that matches the window size, hence there would need to be more than one input to the ensemble model.
Comments.UserDisplayName: Fruity
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-04T17:37:10.063Z
Comments.Text: How would you make an ensemble of these 2 models: Model1: 
  inputA= Input(shape(window_size_A, features))
  hiddenA1= LSTM(units_A1, return_sequences=True)(inputA)
  hiddenA2 = LSTM(units_A2, activation= 'relu')(hiddenA1)
  predictionA = Dense(output_A)(hiddenA2)
  
  Model2: 
  inputB= Input(shape(window_size_B, features))
  hiddenB1= LSTM(units_B1, return_sequences=True)(inputB)
  hiddenB2 = LSTM(units_B2, activation= 'relu')(hiddenB1)
  prediction = Dense(output_B)(hiddenB2)
Comments.UserDisplayName: Fruity
Tags: <python><keras><long-short-term-memory><ensemble-learning>
Title: How to make an ensemble model of two LSTM models with different window sizes i.e. different data shapes
UserDisplayName: Fruity
ThreadText: # How to make an ensemble model of two LSTM models with different window sizes i.e. different data shapes
  
  (Asked by: username_0 on 2021-02-03)
  
  Below is the Python code for making an ensemble model. All the inputs are the same for all three models. But what if the models have different input shapes due to different window size, such as LSTM models. So the input shapes for Model A would be (window_size_A, features) and for Model B would be (window_size_B, features). The window sizes are different but the number of features are the same. As such, due to the different window size, the training data of the same dataset is split differently for each model such that the X_train.shape for model A: (train_data_A, window_size_A, output) And for Model B: (train_data_B, window_size_B, output). Note the training data is from the same dataset but the length is different due to the different window size. How would you make an ensemble of these models?
  def get_model():
      inputs = keras.Input(shape=(128,))
      outputs = layers.Dense(1)(inputs)
      return keras.Model(inputs, outputs)
  
  
  model1 = get_model()
  model2 = get_model()
  model3 = get_model()
  
  inputs = keras.Input(shape=(128,))
  y1 = model1(inputs)
  y2 = model2(inputs)
  y3 = model3(inputs)
  outputs = layers.average([y1, y2, y3])
  ensemble_model = keras.Model(inputs=inputs, outputs=outputs)
  
  **Tags:** python, keras, long-short-term-memory, ensemble-learning
  > **Comments:**
  > **username_1**: So this is a question about implementing ensemble learning in Python?  
  > **username_0**: Yes. I guess so. Although any insight in any regard would be welcome and appreciated.  
  > **username_1**: Perhaps you could clarify your question and make it more specific? It seems like what you're asking is a bit vague and broad.  
  > **username_0**: Sorry about that. I'm new do this. It is about implementing ensemble learning in Python. And about combining two individual lstm models with different window sizes i.e. time steps. This would be that each model can only receive data in a specific shape, a shape that matches the window size, hence there would need to be more than one input to the ensemble model.  
  > **username_0**: How would you make an ensemble of these 2 models: Model1:  inputA= Input(shape(window_size_A, features)) hiddenA1= LSTM(units_A1, return_sequences=True)(inputA) hiddenA2 = LSTM(units_A2, activation= 'relu')(hiddenA1) predictionA = Dense(output_A)(hiddenA2)  Model2:  inputB= Input(shape(window_size_B, features)) hiddenB1= LSTM(units_B1, return_sequences=True)(inputB) hiddenB2 = LSTM(units_B2, activation= 'relu')(hiddenB1) prediction = Dense(output_B)(hiddenB2)  
  
  ---
  
  ## 0 answers
  
  