'Train the model.
Parameters
train_X : array_like
Training data, shape (num_samples, num_features).
train_Y : array_like, optional (default = None)
Reference training data, shape (num_samples, num_features).
val_X : array_like, optional, default None
Validation data, shape (num_val_samples, num_features).
val_Y : array_like, optional, default None
Reference validation data, shape (num_val_samples, num_features).
Returns
self : trained model instance'

def _train_model(self, train_X, train_Y=None, val_X=None, val_Y=None):

    pbar = tqdm(range(self.num_epochs))
    for i in pbar:
        self._run_train_step(train_X)
        if (val_X is not None):
            feed = {self.input_data_orig: val_X, self.input_data: val_X}
            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))
    return self
