title: How to update weights manually with Keras
body: <p>I'm using Keras to build a LSTM and tuning it by doing gradient descent with an external cost function. So the weights are updated with:</p>
  
  <pre><code>weights := weights + alpha* gradient(cost)
  </code></pre>
  
  <p>I know that I can get the weights with <code>keras.getweights()</code>, but how can I do the gradient descent and update all weights and update the weights correspondingly. I try to use <code>initializer</code>, but I still didn't figure it out. I only found some related code with tensorflow but I don't know how to convert it to Keras. </p>
  
  <p>Any help, hint or advice will be appreciated!</p>