title: Different graph after converting tflearn model to keras
body: <p>I have the following code written using tflearn:  </p>
  
  <pre><code>import tflearn
  from tflearn.layers.core import fully_connected, input_data
  from tflearn.layers.estimator import regression
  
  
  def model():
      network = input_data(shape=[None, 5, 1], name='input')
      print('network:', network)
      # Outputs: network: Tensor("input/X:0", shape=(?, 5, 1), dtype=float32)
      network = fully_connected(network, 25, activation='relu')
      print('fully_network_1:', network)
      # Outputs: fully_network_1: Tensor("FullyConnected/Relu:0", shape=(?, 25), dtype=float32)
      network = fully_connected(network, 1, activation='linear')
      print('fully_network_2:', network)
      # Outputps: fully_network_2: Tensor("FullyConnected_1/BiasAdd:0", shape=(?, 1), dtype=float32)
      network = regression(network, optimizer='adam', learning_rate=self.lr,
                           loss='mean_square', name='target')
      print('reg:', network)
      # Outputs: reg: Tensor("FullyConnected_1/BiasAdd:0", shape=(?, 1), dtype=float32)
      model = tflearn.DNN(network, tensorboard_dir='log', tensorboard_verbose=3)
      return model
  </code></pre>
  
  <p>The created model is trained using the following code:  </p>
  
  <pre><code>def train_model(train_x, train_y, model):
      train_x = train_x.reshape(-1, 5, 1)
      train_y = train_y.reshape(-1, 1)
      print(train_x.shape)
      # Outputs: (599068, 5, 1)
      print(train_y.shape)
      # Outputs: (599068, 1)
      model.fit(train_x, train_y, n_epoch=3, shuffle=True, run_id='model.tflearn')
      model.save('model.tflearn')
  </code></pre>
  
  <p>When I display the graph using Tensorboard, I get the following graph:  </p>
  
  <p><a href="https://i.stack.imgur.com/lfBOV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lfBOV.png" alt="enter image description here"></a> </p>
  
  <p>I wanted to migrate to Tensorflow 2.2.0 (from Tensorflow 1.15.0), so I decided to rewrite the previous code using Tensorflow2, here is my code:  </p>
  
  <pre><code>import tensorflow as tf
  
  
  def build_model():
      model = tf.keras.Sequential()
      model.add(tf.keras.layers.Dense(units=25, activation='relu',
                                      input_shape=(5, 1)))
      model.add(tf.keras.layers.Dense(units=1, activation='linear'))
      opt = tf.keras.optimizers.Adam(learning_rate=0.01, beta_1=0.9,
                                     beta_2=0.999, epsilon=1e-07,
                                     amsgrad=False, name='Adam')
      model.compile(optimizer=opt, loss='mse')
      print(model.summary())
      return model
  </code></pre>
  
  <p>The model summary returns:  </p>
  
  <pre><code>Model: "sequential"
  _________________________________________________________________
  Layer (type)                 Output Shape              Param #   
  =================================================================
  dense (Dense)                (None, 5, 25)             50        
  _________________________________________________________________
  dense_1 (Dense)              (None, 5, 1)              26        
  =================================================================
  Total params: 76
  Trainable params: 76
  Non-trainable params: 0
  _________________________________________________________________
  None
  </code></pre>
  
  <p>The created model is trained using the following code:  </p>
  
  <pre><code>import datetime
  import tensorflow as tf
  
  
  def train(model, train_x, train_y):
      train_x = train_x.reshape(-1, 5, 1)
      train_y = train_y.reshape(-1, 1)
      # train_x.shape = (599068, 5, 1)
      # train_y.shape = (599068, 1)
      log_dir = "logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
      tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
  
      model.fit(train_x, train_y, epochs=3, verbose=1, callbacks=[tensorboard_callback])
      model.save_weights('model.h5')
  </code></pre>
  
  <p>When I display the model's graph I got this:  </p>
  
  <p><a href="https://i.stack.imgur.com/zjrVP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zjrVP.png" alt="enter image description here"></a></p>
  
  <p>This is totally different from the graph I got with tflearn.<br>
  Did I miss something when building the model with Tensorflow?  </p>
  
  <p><strong>Notice:</strong> I got different losses when I train both models, the first model's loss is 0.06, while the model built with Tensorflow2 has 0.25 as loss, which is far from the first one! </p>