Beispiel #1
0
    def __init__(self, models_dir, fold_name, writer=None, hyper=None):
        self._graph = tf.Graph()
        with self._graph.as_default():
            reader = Reader(fold_name)
            with tf.device('/gpu:1'):
                self._input = reader.inputs(Trainer.BATCH_SIZE, is_train=True)
                self._network = Network(self._input['images'],
                                        is_train=True,
                                        hyper=hyper)
                self._cross_entropy_losses = self._network.cross_entropy_losses(
                    self._input['labels'])
                self._total_loss = self._network.total_loss(
                    self._input['labels'])
                self._lr_placeholder = tf.placeholder(tf.float32)
                self._train = self._train_op()
                self._all_summaries = tf.merge_all_summaries()

        self.models_dir = models_dir
        print('Trainer model folder: %s' % self.models_dir)
        if not tf.gfile.Exists(self.models_dir):
            tf.gfile.MakeDirs(self.models_dir)

        self.writer = writer
        if (self.writer):
            self.writer.write_graph(self._graph)
Beispiel #2
0
def inputs(eval_data):
    if not FLAGS.data_dir:
        raise ValueError('Please supply a data_dir')
    data_dir = os.path.join(FLAGS.data_dir, 'Data')
    images, labels = reader.inputs(eval_data=eval_data,
                                   data_dir=data_dir,
                                   batch_size=FLAGS.batch_size)
    if FLAGS.use_fp16:
        images = tf.cast(images, tf.float16)
        labels = tf.cast(labels, tf.float16)
    return images, labels
Beispiel #3
0
  def __init__(self, models_dir, fold_name, writer=None, hyper=None):
    self._graph = tf.Graph()
    with self._graph.as_default():
      reader = Reader(fold_name)
      self.fold_size = reader.fold_size
      with tf.device('/gpu:1'):
        self._input = reader.inputs(Tester.BATCH_SIZE, is_train=False)
        self._network = Network(self._input['images'], is_train=False, hyper=hyper)
        self._probs = self._network.probs()
        self._cross_entropy_losses = self._network.cross_entropy_losses(self._input['labels'])
        self._all_summaries = tf.merge_all_summaries()

    self.models_dir = models_dir
    print('Tester model folder: %s' %self.models_dir)
    assert os.path.exists(self.models_dir)

    self.writer = writer
  def __init__(self, models_dir, fold_name, writer=None, hyper=None):
    self._graph = tf.Graph()
    with self._graph.as_default():
      reader = Reader(fold_name)
      self.fold_size = reader.fold_size
      with tf.device('/gpu:1'):
        images, self._labels, scores, self._filenames = reader.inputs(Tester.BATCH_SIZE, is_train=False)
        self._network = Network(images, is_train=False, hyper=hyper, features=scores)
        self._probs = self._network.probs()
        self._loss = self._network.loss(self._labels)
        self._all_summaries = tf.merge_all_summaries()

    self.models_dir = models_dir
    print('Tester model folder: %s' %self.models_dir)
    assert os.path.exists(self.models_dir)

    self.writer = writer
  def __init__(self, models_dir, fold_name, writer=None, hyper=None):
    self._graph = tf.Graph()
    with self._graph.as_default():
      reader = Reader(fold_name)
      with tf.device('/gpu:1'):
        images, labels, scores, _ = reader.inputs(Trainer.BATCH_SIZE, is_train=True)
        self._network = Network(images, is_train=True, hyper=hyper, features=scores)
        self._loss = self._network.loss(labels)
        self._lr_placeholder = tf.placeholder(tf.float32)
        self._train = self._train_op()
        self._all_summaries = tf.merge_all_summaries()

    self.models_dir = models_dir
    print('Trainer model folder: %s' %self.models_dir)
    if not tf.gfile.Exists(self.models_dir):
      tf.gfile.MakeDirs(self.models_dir)

    self.writer = writer
    if (self.writer):
      self.writer.write_graph(self._graph)