import tensorflow as tf

  def _train_semi_supervised(self, dataset, start_epoch, weights_from, summary_every, model_name,
                             weights_dir):
    training_X, training_y, validation_X, validation_y = \
        dataset.training_X, dataset.training_y, dataset.validation_X, dataset.validation_y
    if not os.path.exists(weights_dir):
      os.mkdir(weights_dir)
    if not os.path.exists(weights_dir + '/best_models'):
      os.mkdir(weights_dir + '/best_models')

    # Create a saver.
    saver = tf.train.Saver(max_to_keep=None)
    if self.is_summary:
      training_batch_summary_op = tf.merge_all_summaries(key=TRAINING_BATCH_SUMMARIES)
      training_epoch_summary_op = tf.merge_all_summaries(key=TRAINING_EPOCH_SUMMARIES)
      validation_batch_summary_op = tf.merge_all_summaries(key=VALIDATION_BATCH_SUMMARIES)
      validation_epoch_summary_op = tf.merge_all_summaries(key=VALIDATION_EPOCH_SUMMARIES)

    # Build an initialization operation to run below.
    init = tf.global_variables_initializer()

    gpu_options = tf.GPUOptions(
        per_process_gpu_memory_fraction=self.cnf.get('gpu_memory_fraction', 0.9))
    sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True, gpu_options=gpu_options))
    sess.run(init)
    if start_epoch > 1:
      weights_from = "weights/model-epoch-%d.ckpt" % (start_epoch - 1)

    if weights_from:
