def _train_model(self, train_set, train_ref=None, validation_set=None,
                      Validation_ref=None):
        """Train the model.

        :param train_set: training set
        :param validation_set: validation set. optional, default None
        :return: self
        """
        pbar = tqdm(range(self.num_epochs))
        for i in pbar:
            self._run_train_step(train_set)

            if validation_set is not None:
                feed = self._create_feed_dict(validation_set)
                err = tf_utils.run_summaries(
                    self.tf_session, self.tf_merged_summaries,
                    self.tf_summary_writer, i, feed, self.cost)
                pbar.set_description("Reconstruction loss: %s" % (err))
Train the model.

        :param train_set: training set
        :param validation_set: validation set. optional, default None
        :return: self
        
yadlt/models/boltzmann/rbm.py