Full explanation can be found in this blog post. The source code is compatible with TensorFlow 1.1 and Keras 2.0.4
Interested in deeper understanding of Machine Learning algorithms? Implement them in Python from scratch:
Read the book here