title: Using tf.split or tf.slice for keras layers
body: <p>I want to split my training samples of size <code>[batchSize, 2, 16]</code> into 16 tensors of size <code>[batchSize, 2]</code> and input them to the same model. How can I accomplish them in keras?</p>
  
  <p>I have first implemented this in following way,</p>
  
  <pre><code>def functionA(x_Config):
  
      y = layers.Input(shape=(2,16,))
  
      hidden1 = 5
      hidden2 = 10
  
      x_input = layers.Input(shape=(2,))
      hidden_layer1 = Dense(hidden1, activation='relu')(x_input)
      hidden_layer2 = Dense(hidden2, activation='relu')(hidden_layer1)
      x_output = Dense(x_Config.m, activation='linear')(hidden_layer2)
      model_x= Model(inputs=x_input, outputs=x_output)
  
  
      for i in range(16):
          x_input = Lambda(lambda x: x[:, :, i])(y)
  
          if i == 0:
             x_output = model_x(x_input)
          else:
              x_output = layers.concatenate([x_output, 
                                        model_x(x_input)])
  
      x_output = Lambda(lambda x: x[:, :tf.cast(N, tf.int32)])(x_output)
  
      final_model = Model(y, x_output)
  
      return final_model
  </code></pre>
  
  <p>PS: I have a trained model for the same NN architecture for <code>model_x</code> for <code>[batchSize, 2]</code> inputs (without the need for splitting). This model performs very well. When I tried to load the weights of that model to above mentioned code, <code>model_x</code>, it does not give good performance at all and does not train well. </p>
  
  <p>So I believe my problems lies inside the loop in the Lamda layer. How can I use <code>tf.split</code> or <code>tf.slice</code> for this?</p>