Creating a DBN with the Keras Model API

Learn how to implement deep belief networks (DBN) using TensorFlow 2.0.

The creation of a single-layer RBM to generate images is the building block required to create a full-fledged DBN. Usually, for a model in TensorFlow 2, we only need to extend tf.keras.Model and define an initialization (where the layers are defined) and a call function (for the forward pass). For our DBN model, we also need a few more custom functions to define its behavior.

Implementing the RBM

Let’s continue by combining multiple RBMs in layers to create a more powerful model—the deep belief network (DBN).

RBM initialization

First, in the initialization, we need to pass a list of dictionaries that contain the parameters for our RBM layers (number_hidden_unitsnumber_visible_units, and learning_rate, cd_steps):

Get hands-on with 1400+ tech skills courses.