'Train the model.
:param train_set: training set
:param train_ref: training reference data
:param validation_set: validation set
:param validation_ref: validation reference data
:return: self'

def _train_model(self, train_set, train_ref, validation_set, validation_ref):

    shuff = list(zip(train_set, train_ref))
    pbar = tqdm(range(self.num_epochs))
    for i in pbar:
        np.random.shuffle(shuff)
        batches = [_ for _ in utilities.gen_batches(shuff, self.batch_size)]
        for batch in batches:
            (x_batch, y_batch) = zip(*batch)
            self.tf_session.run(self.train_step, feed_dict={self.input_data: x_batch, self.input_labels: y_batch, self.keep_prob: self.dropout})
        if (validation_set is not None):
            feed = {self.input_data: validation_set, self.input_labels: validation_ref, self.keep_prob: 1}
            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))
