title: Can I train the initial hidden state of a RNN to represent the initial conditions of my model?
body: <p>I have some time-series data related to a bioreactor. Every 24h I feed glucose to the bioreactor and measure how much of some substances it produced since last feed.</p>
  <p><strong>Input</strong>: Glucose feed.</p>
  <p><strong>Ouput</strong>: Production of substances.</p>
  <p><strong>Objective</strong>: Estimate these substances concentrations over time, given the glucose I fed.</p>
  <p>This bioreactor has some <strong>initial conditions</strong>, like <strong>initial concentration of glucose and substances</strong>. Each experiment has a different initial condition. In one experiment I can start with 10mM of a substance, and in another I can start with 100mM, so knowing the starting point is important.</p>
  <p>I wanted use to this initial condition to train the initial hidden state of my RNN.</p>
  <p><a href="https://i.stack.imgur.com/Cpk1Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cpk1Q.png" alt="Model" /></a></p>
  <p>Is there anyway that I can do that? If not, are there other ways to express initial conditions to a RNN? I am using python with Keras. Thanks!</p>
  <p>In code, I believe it would look something like this:</p>
  <pre><code>from tensorflow.keras.layers import Input, Dense, LSTM
  from tensorflow.keras.models import Model
  from tensorflow.keras.optimizers import Adam
  
  input_layer = Input(shape=(16,3))
  hidden_state_dim = 7
  
  mlp_inp = Input(batch_shape=(hidden_state_dim,1))
  mlp_dense_h = Dense(hidden_state_dim, activation='relu')(mlp_inp)
  mlp_dense_c = Dense(hidden_state_dim, activation='relu')(mlp_inp)
  
  x = LSTM(7, return_sequences = True)(input_layer, initial_state=[mlp_dense_h, mlp_dense_c])
  
  model = Model(input_layer, x)
  </code></pre>
  <p>But I receive the ValueError: Graph disconnected. Probably because there is no backpropagation to the mlp_dense_h/c.</p>