title: How do I get the weights of a layer in Keras?
body: <p>I am using Windows 10, Python 3.5, and tensorflow 1.1.0. I have the following script:</p>
  
  <pre><code>import tensorflow as tf
  import tensorflow.contrib.keras.api.keras.backend as K
  from tensorflow.contrib.keras.api.keras.layers import Dense
  
  tf.reset_default_graph()
  init = tf.global_variables_initializer()
  sess =  tf.Session()
  K.set_session(sess) # Keras will use this sesssion to initialize all variables
  
  input_x = tf.placeholder(tf.float32, [None, 10], name='input_x')    
  dense1 = Dense(10, activation='relu')(input_x)
  
  sess.run(init)
  
  dense1.get_weights()
  </code></pre>
  
  <p>I get the error: <code>AttributeError: 'Tensor' object has no attribute 'weights'</code></p>
  
  <p>What am I doing wrong, and how do I get the weights of <code>dense1</code>? I have look at <a href="https://stackoverflow.com/questions/42053170/keras-how-can-i-get-biasess-weights">this</a> and <a href="https://stackoverflow.com/questions/42411891/how-to-extract-bias-weights-in-keras-sequential-model">this</a> SO post, but I still can't make it work.</p>