def log_run_start(run_type, hyper_dict, version_description): """ Log the start info of a neural network run """ dl_data = (DATASET_NAME, run_type) return log.dl_run_start(DL_RUN, DL_NETWORK, DL_MODEL_FILE_PATH, dl_data, \ hyper_dict, version_description)
dl_network = 'Lenet' dl_model_file_path = 'tf_lenet.py' dl_data = ('TF_MNIST', 'Train') dl_environment = 'Default' hyper_dict = { 'epochs' : EPOCHS, 'batch size' : BATCH_SIZE, 'learning rate' : \ LEARNING_RATE } # Train the model with tf.Session() as sess: sess.run(tf.global_variables_initializer()) num_examples = len(X_train) print("Training...") run_id = log.dl_run_start(dl_run, dl_network, dl_model_file_path, dl_data, hyper_dict) print() for i in range(EPOCHS): X_train, y_train = shuffle(X_train, y_train) for offset in range(0, num_examples, BATCH_SIZE): end = offset + BATCH_SIZE batch_x, batch_y = X_train[offset:end], y_train[offset:end] sess.run(training_operation, feed_dict={x: batch_x, y: batch_y}) validation_accuracy = evaluate(X_validation, y_validation) print("EPOCH {} ...".format(i+1)) print("Validation Accuracy = {:.3f}".format(validation_accuracy)) print() saver.save(sess, 'lenet')