Exemplo n.º 1
0
                        print("TRAIN IMAGE #"+str(train_batch_size*batchs))
                    if epoch_over is True:
                        print("END EPOCH "+str(epochs)) 
                end = timer()
                total_batchs += batchs
                print("TRAIN TIME ELAPSED "+str(end-start))

                ###test on unseen data, init variables
                print("BEGIN TESTING")
                start = timer()
                batchs = 0 
                epoch_over = False
                accuracy = []
                ###begin testing/validation loop, use entire validation dataset
                while not epoch_over:
                    test_batch, one_hots, epoch_over = trainer.get_test_batch(test_batch_size)
                    #get predicted class of test data from model 
                    prediction = sess.run([net.output], feed_dict={net.inputs:test_batch})[0]
                    accuracy.append(np.mean(np.equal(np.argmax(prediction, axis=1), np.argmax(one_hots, axis=1)).astype("float32")))
                    batchs += 1
                    if batchs % 5 == 0:
                        print("TEST IMAGE #"+str(test_batch_size*batchs))
                    if epoch_over is True:
                        print("TEST EPOCH OVER")
                epoch_over = False
                batchs = 0
                test_accuracy = np.mean(accuracy)
                print("TEST ACCURACY "+str(test_accuracy))
                write_to_tensorboard("Accuracy/Test Data", test_accuracy, epochs, summary_writer)
                end = timer()
                print("TEST TIME ELAPSED "+str(end-start))