Creating an RBM using the TensorFlow Keras layers API

Learn how to implement Restricted Boltzmann Machines using TensorFlow 2.0.

Now that we have an appreciation of some of the theoretical underpinnings of the RBM, let's learn how we can implement it using the TensorFlow 2 library. For this purpose, we’ll represent the RBM as a custom layer type using the Keras layers API. We’ll implement the whole model in code, showing how we can leverage TensorFlow 2’s gradient tape functionality to implement CD as a custom learning algorithm.

Implementing the RBM

Firstly, we extend tf.keras.layer:

Get hands-on with 1400+ tech skills courses.