title: Why get_tensor_by_name can't get the weights of layers defined by tf.keras.layers properly
body: <p>I try to get the weights of layers defined by <code>tf.keras.layers</code> by using <code>get_tensor_by_name</code> in <code>tensorflow</code>. The code is presented as follows</p>
  
  <pre><code># encoding: utf-8
  import tensorflow as tf
  
  x = tf.placeholder(tf.float32, (None,3))
  h = tf.keras.layers.dense(3)(x)
  y = tf.keras.layers.dense(1)(h)
  
  for tn in tf.trainable_variables():
      print(tn.name)
  
  sess = tf.Session()
  sess.run(tf.global_variables_initializer())
  w = tf.get_default_graph().get_tensor_by_name("dense/kernel:0")
  print(sess.run(w))
  </code></pre>
  
  <p>The name of the weight is <code>dense/kernel:0</code>. However, the output of <code>sess.run(w)</code> is weird</p>
  
  <pre><code>[( 10,) ( 44,) ( 47,) (106,) (111,) ( 98,) ( 58,) (108,) (111,) ( 99,)
   ( 97,) (108,) (104,) (111,) (115,) (116,) ( 47,) (114,) (101,) 
   ... ]
  </code></pre>
  
  <p>which is not an array of floats. In fact, if I use <code>tf.layers.dense</code> to define the network, everything goes fine. So my question is that how I can get the weights of layers defined by <code>tf.keras.layers</code> by using tensor name properly.</p>