Exemplo n.º 1
0
accuracy = 0

with tf.Session() as sess:
    sess.run(init)
    actual_steps = 0
    runs = 0
    index = 0

    testlength = int(len(itest) / 70)

    saver.restore(sess, var_export_dir)

    for i in range((actual_steps - runs), steps):

        matches = tf.equal(tf.argmax(y_pred, 1), tf.argmax(y_true, 1))
        test_x, test_y, index = nextImageBatch(itest, testlength,
                                               len(subfolders), index)

        acc = tf.reduce_mean(tf.cast(matches, tf.float32))

        print("ACCURACY: ")
        get_acc = sess.run(acc,
                           feed_dict={
                               x_image: test_x,
                               y_true: test_y,
                               hold_prob: 1.0
                           })
        print(get_acc)

        test_saver.write(str(get_acc) + '\n')

        accuracy = accuracy + get_acc
Exemplo n.º 2
0
    #saver.restore(sess, var_export_dir)
    
    for i in range((actual_steps-runs), steps):

        # We will check time required to run each step using start_time and end_time
        train_time_saver = open('<PATH>/TempFM2/train_time.txt', 'a+')
        start_time = time.time()

        print('Saving step number');
        step_saver.write(str(i) + '\n')

        step_saver.close()

        step_saver = open('<PATH>/TempFM2/steps.txt', 'a+')

        batch_x, batch_y, index = nextImageBatch(itrain, trainlength, len(subfolders), index)
        
        sess.run(train, feed_dict={x_image:batch_x, y_true:batch_y, pool_prob:0.75, hold_prob:0.5})
        #print(trainlength)
        
        #print accuracy every few steps
        if (i+1)%10==0:
            i1 = 0
            print("ON STEP {}".format(i))
            matches = tf.equal(tf.argmax(y_pred, 1), tf.argmax(y_true, 1))
            test_x, test_y, i1 = nextImageBatch(itest, testlength, len(subfolders), i1)
            
            acc = tf.reduce_mean(tf.cast(matches, tf.float32))
            print("ACCURACY: ")
            accuracy = sess.run(acc, feed_dict={x_image:test_x, y_true:test_y, pool_prob:1.0, hold_prob:1.0})
            print(accuracy)