def test(self, writer): if self.use_exif_summary: exif_start = time.time() test_queue = self.net.train_runner.get_random_test( batch_size=self.net.batch_size) to_print = [] for i, (im_a_batch, im_b_batch, label_batch) in enumerate(test_queue): tag = self.net.train_runner.tags[i] output = self.sess.run(self.net.pred, feed_dict={ self.net.im_a: im_a_batch, self.net.im_b: im_b_batch, self.net.label: label_batch, self.net.is_training: False }) tag_acc = 100.0 * ( np.sum(np.round(output[:, i]) == label_batch[:, i]) / float(self.net.batch_size)) summary = self.sess.run( self.individual_summary[tag], feed_dict={self.tag_holder[tag]: tag_acc}) io.add_summary(writer, [summary], self.i) to_print.append([tag, tag_acc]) io.show(to_print, phase='test', iter=self.i) print('EXIF test accuracy evaluation took %.2f seconds' % (time.time() - exif_start)) return
def show(self, writer, phase='train'): if self.net.use_tf_threading: summary = self.sess.run(self.summary) else: args = self.get_data(self.net.batch_size, phase) summary = self.sess.run(self.summary, feed_dict=args) io.add_summary(writer, summary, self.i) io.show([['Train time', np.mean(list(self.train_timer))]], phase=phase, iter=self.i) return