def main(): t = time() check_flags() print(get_model_info_as_str()) data_train = SiameseModelData(FLAGS.dataset_train) dist_sim_calculator = DistSimCalculator( FLAGS.dataset_train, FLAGS.ds_metric, FLAGS.ds_algo) model = create_model(FLAGS.model, data_train.input_dim(), data_train, dist_sim_calculator) os.environ["CUDA_VISIBLE_DEVICES"] = str(FLAGS.gpu) config = tf.ConfigProto() config.gpu_options.allow_growth = True sess = tf.Session(config=config) saver = Saver(sess) sess.run(tf.global_variables_initializer()) if FLAGS.dataset_val_test == FLAGS.dataset_train: data_val_test = data_train else: # Generalizability test: val test on unseen train and test graphs. data_val_test = SiameseModelData(FLAGS.dataset_val_test) eval = Eval(data_val_test, dist_sim_calculator) try: train_costs, train_times, val_results_dict = \ train_val_loop(data_train, data_val_test, eval, model, saver, sess) best_iter, test_results = \ test(data_val_test, eval, model, saver, sess, val_results_dict) overall_time = convert_long_time_to_str(time() - t) print(overall_time) saver.save_overall_time(overall_time) except: traceback.print_exc() else: return train_costs, train_times, val_results_dict, best_iter, test_results
def main(): check_flags() data = SiameseModelData() dist_calculator = DistCalculator(FLAGS.dataset, FLAGS.dist_metric, FLAGS.dist_algo) model = create_model(FLAGS.model, data.input_dim()) sess = tf.Session() saver = Saver(sess) sess.run(tf.global_variables_initializer()) train_costs, train_times, val_costs, val_times = \ train_val(data, dist_calculator, model, saver, sess) results = \ test(data, dist_calculator, model, saver, sess) return train_costs, train_times, val_costs, val_times, results
def main(): t = time() check_flags() print(get_model_info_as_str()) data = SiameseModelData() dist_calculator = DistCalculator( FLAGS.dataset, FLAGS.dist_metric, FLAGS.dist_algo) model = create_model(FLAGS.model, data.input_dim(), data, dist_calculator) os.environ["CUDA_VISIBLE_DEVICES"] = str(FLAGS.gpu) config = tf.ConfigProto() config.gpu_options.allow_growth=True sess = tf.Session(config=config) saver = Saver(sess) sess.run(tf.global_variables_initializer()) eval = Eval(data, dist_calculator) train_costs, train_times, val_results_dict = \ train_val_loop(data, eval, model, saver, sess) best_iter, test_results = \ test(data, eval, model, saver, sess, val_results_dict) overall_time = convert_long_time_to_str(time() - t) print(overall_time) saver.save_overall_time(overall_time) return train_costs, train_times, val_results_dict, best_iter, test_results
def main(): t = time() conf_code = extract_config_code() check_flags() print(get_model_info_as_str()) data = SiameseModelData(FLAGS.dataset_train) dist_sim_calculator = DistSimCalculator(FLAGS.dataset_train, FLAGS.ds_metric, FLAGS.ds_algo) model = create_model(FLAGS.model, data.input_dim(), data, dist_sim_calculator) os.environ["CUDA_VISIBLE_DEVICES"] = str(FLAGS.gpu) config = tf.compat.v1.ConfigProto() config.gpu_options.allow_growth = True sess = tf.compat.v1.Session(config=config) saver = Saver(sess) sess.run(tf.compat.v1.global_variables_initializer()) train_costs, train_times = train_loop(data, model, saver, sess) test(data, model, saver, sess) saver.save_conf_code(conf_code) overall_time = convert_long_time_to_str(time() - t) print(overall_time, saver.get_log_dir()) saver.save_overall_time(overall_time) return train_costs, train_times