Пример #1
0
                if TRAIN_RATIO < 1.0:
                    validation_accuracy = evaluate(X_VALID, Y_VALID, batch_size)
                else:
                    validation_accuracy = None
                print("EPOCH {} ...".format(i+1))
                print("Training Loss = {:.3f}".format(loss))
                if validation_accuracy is not None:
                    print("Validation Accuracy = {:.3f}".format(validation_accuracy))
                print()
                epoch_train_time_list.append(time() - t1)
                training_losses.append(loss)
                validate_accuracies.append(validation_accuracy)

            saver.save(sess, save_file)
            print("Model saved")
            log_run_end(run_id, validation_accuracy, loss)
        print()
        print("Total training time:        {:.2f}".format(time() - t0))
        print("Mean epoch training time:   {:.2f}".format(st.mean(epoch_train_time_list)))
        print("Epoch training time stdev:  {:.2f}".format(st.pstdev(epoch_train_time_list)))
        print()

    # Evaluate the model with test data
    with tf.Session() as sess:
        saver.restore(sess, tf.train.latest_checkpoint('.'))

        run_id = log_run_start('Test', hyper_dict, VERSION_DESCRIPTION,)

        test_accuracy = evaluate(X_TEST, Y_TEST, batch_size)
        print("Test Accuracy = {:.3f}".format(test_accuracy))
Пример #2
0
                    _, validation_accuracy = evaluate(X_VALID, Y_VALID, LOGITS, SOFTMAX, \
                        batch_size)
                else:
                    validation_accuracy = None
                print("EPOCH {} ...".format(i+1))
                print("Training Loss = {:.3f}".format(loss))
                if validation_accuracy is not None:
                    print("Validation Accuracy = {:.3f}".format(validation_accuracy))
                print()
                epoch_train_time_list.append(time() - t1)
                training_losses.append(loss)
                validate_accuracies.append(validation_accuracy)

            SAVER.save(sess, SAVE_FILE)
            print("Model saved")
            log_run_end(run_id, validation_accuracy, loss)
        print()
        print("Total training time:        {:.2f}".format(time() - t0))
        print("Mean epoch training time:   {:.2f}".format(st.mean(epoch_train_time_list)))
        print("Epoch training time stdev:  {:.2f}".format(st.pstdev(epoch_train_time_list)))
        print()

    # Evaluate the model with test data
    with tf.Session() as sess:
        SAVER.restore(sess, tf.train.latest_checkpoint('.'))

        run_id = log_run_start('Test', hyper_dict, VERSION_DESCRIPTION,)

        _, TEST_ACCURACY = evaluate(X_TEST, Y_TEST, LOGITS, SOFTMAX, batch_size)
        print("Test Accuracy = {:.3f}".format(TEST_ACCURACY))