Exemplo n.º 1
0
                                    shape=[None, IMAGE_PIXELS],
                                    name='images')

labels_placeholder = tf.placeholder(tf.int64,
                                    shape=[None],
                                    name='image-labels')

logits = two_layer_fc.inference(images_placeholder,
                                IMAGE_PIXELS,
                                FLAGS.hidden1,
                                CLASSES,
                                reg_constant=FLAGS.reg_constant)

global_step = tf.Variable(0, name="global_step", trainable=False)

accuracy = two_layer_fc.evaluation(logits, labels_placeholder)

saver = tf.train.Saver()

with tf.Session() as sess:
    ckpt = tf.train.get_checkpoint_state(FLAGS.train_dir)
    if ckpt and ckpt.model_checkpoint_path:
        print('Restoring variables from checkpoint')
        saver.restore(sess, ckpt.model_checkpoint_path)
        current_step = tf.train.global_step(sess, global_step)
        print('Current step: {}'.format(current_step))

    print('Test accuracy {:g}'.format(
        accuracy.eval(
            feed_dict={
                images_placeholder: data_sets['images_test'],
Exemplo n.º 2
0
beginTime = time.time()

data_sets = data_helpers.load_data()

images_placeholder = tf.placeholder(tf.float32, shape=[None, IMAGE_PIXELS],
  name='images')

labels_placeholder = tf.placeholder(tf.int64, shape=[None], name='image-labels')

logits = two_layer_fc.inference(images_placeholder, IMAGE_PIXELS,
  FLAGS.hidden1, CLASSES, reg_constant=FLAGS.reg_constant)

global_step = tf.Variable(0, name="global_step", trainable=False)

accuracy = two_layer_fc.evaluation(logits, labels_placeholder)

saver = tf.train.Saver()

with tf.Session() as sess:
  ckpt = tf.train.get_checkpoint_state(FLAGS.train_dir)
  if ckpt and ckpt.model_checkpoint_path:
    print('Restoring variables from checkpoint')
    saver.restore(sess, ckpt.model_checkpoint_path)
    current_step = tf.train.global_step(sess, global_step)
    print('Current step: {}'.format(current_step))

  print('Test accuracy {:g}'.format(accuracy.eval(
    feed_dict={ images_placeholder: data_sets['images_test'],
                labels_placeholder: data_sets['labels_test']}
  )))