def _build_model(self):
    '\n        BUilding the Restriced Boltzman Machine in Tensorflow\n        '
    (self.input_data, self.hrand) = self._create_placeholders()
    (self.W, self.bh_, self.bv_, self.dw, self.dbh_, self.dbv_) = self._create_variables()
    (hprobs0, hstates0, vprobs, hprobs1, hstates1) = self.gibbs_sampling_step(self.input_data)
    positive = self.compute_positive_association(self.input_data, hprobs0, hstates0)
    nn_input = vprobs
    for step in range((self.gibbs_sampling_steps - 1)):
        (hprobs, hstates, vprobs, hprobs1, hstates1) = self.gibbs_sampling_step(nn_input)
        nn_input = vprobs
    self.reconstruct = vprobs
    negative = tf.matmul(tf.transpose(vprobs), hprobs1)
    self.encode = hprobs1
    dw = (positive - negative)
    self.dw = ((self.momentum * self.dw) + ((1 - self.momentum) * dw))
    self.w_upd8 = self.W.assign_add(((self.learning_rate * self.dw) - ((self.learning_rate * self.l2) * self.W)))
    dbh_ = tf.reduce_mean((hprobs0 - hprobs1), 0)
    self.dbh_ = ((self.momentum * self.dbh_) + (self.learning_rate * dbh_))
    self.bh_upd8 = self.bh_.assign_add(self.dbh_)
    dbv_ = tf.reduce_mean((self.input_data - vprobs), 0)
    self.dbv_ = ((self.momentum * self.dbv_) + (self.learning_rate * dbv_))
    self.bv_upd8 = self.bv_.assign_add(self.dbv_)
    self.loss_function = tf.sqrt(tf.reduce_mean(tf.square((self.input_data - vprobs))))
    self.batch_cost = tf.sqrt(tf.reduce_mean(tf.square((self.input_data - vprobs)), 1))
    self._create_free_energy_for_batch()
BUilding the Restriced Boltzman Machine in Tensorflow
def _build_model(self):
    '\n        \n        '
    (self.input_data, self.hrand) = self._create_placeholders()
    (self.W, self.bh_, self.bv_, self.dw, self.dbh_, self.dbv_) = self._create_variables()
    (hprobs0, hstates0, vprobs, hprobs1, hstates1) = self.gibbs_sampling_step(self.input_data)
    positive = self.compute_positive_association(self.input_data, hprobs0, hstates0)
    nn_input = vprobs
    for step in range((self.gibbs_sampling_steps - 1)):
        (hprobs, hstates, vprobs, hprobs1, hstates1) = self.gibbs_sampling_step(nn_input)
        nn_input = vprobs
    self.reconstruct = vprobs
    negative = tf.matmul(tf.transpose(vprobs), hprobs1)
    self.encode = hprobs1
    dw = (positive - negative)
    self.dw = ((self.momentum * self.dw) + ((1 - self.momentum) * dw))
    self.w_upd8 = self.W.assign_add(((self.learning_rate * self.dw) - ((self.learning_rate * self.l2) * self.W)))
    dbh_ = tf.reduce_mean((hprobs0 - hprobs1), 0)
    self.dbh_ = ((self.momentum * self.dbh_) + (self.learning_rate * dbh_))
    self.bh_upd8 = self.bh_.assign_add(self.dbh_)
    dbv_ = tf.reduce_mean((self.input_data - vprobs), 0)
    self.dbv_ = ((self.momentum * self.dbv_) + (self.learning_rate * dbv_))
    self.bv_upd8 = self.bv_.assign_add(self.dbv_)
    self.loss_function = tf.sqrt(tf.reduce_mean(tf.square((self.input_data - vprobs))))
    self.batch_cost = tf.sqrt(tf.reduce_mean(tf.square((self.input_data - vprobs)), 1))
    self._create_free_energy_for_batch()