timenow = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime(time.time())) fh = logging.FileHandler('log/{}.log'.format(str(args.prefix) + timenow)) fh.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.WARN) formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) logger.addHandler(fh) logger.addHandler(ch) logger.info(args) ### Extract data for training, validation and testing node_features, edge_features, full_data, train_data, val_data, test_data, new_node_val_data, \ new_node_test_data = get_data(DATA, different_new_nodes_between_val_and_test=args.different_new_nodes) # Initialize training neighbor finder to retrieve temporal graph train_ngh_finder = get_neighbor_finder(train_data, args.uniform) # Initialize validation and test neighbor finder to retrieve temporal graph full_ngh_finder = get_neighbor_finder(full_data, args.uniform) # Initialize negative samplers. Set seeds for validation and testing so negatives are the same # across different runs # NB: in the inductive setting, negatives are sampled only amongst other new nodes train_rand_sampler = RandEdgeSampler(train_data.sources, train_data.destinations) val_rand_sampler = RandEdgeSampler(full_data.sources, full_data.destinations, seed=0)
logger.setLevel(logging.DEBUG) Path("log/").mkdir(parents=True, exist_ok=True) fh = logging.FileHandler('log/{}.log'.format(str(time.time()))) fh.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.WARN) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) logger.addHandler(fh) logger.addHandler(ch) logger.info(args) ### Extract data for training, validation and testing node_features, edge_features, full_data, train_data, val_data, test_data, new_node_val_data, \ new_node_test_data = get_data(DATA, different_new_nodes_between_val_and_test=args.different_new_nodes, randomize_features=args.randomize_features) # Initialize training neighbor finder to retrieve temporal graph train_ngh_finder = get_neighbor_finder(train_data, args.uniform) # Initialize validation and test neighbor finder to retrieve temporal graph full_ngh_finder = get_neighbor_finder(full_data, args.uniform) # Initialize negative samplers. Set seeds for validation and testing so negatives are the same # across different runs # NB: in the inductive setting, negatives are sampled only amongst other new nodes train_rand_sampler = RandEdgeSampler(train_data.sources, train_data.destinations) val_rand_sampler = RandEdgeSampler(full_data.sources, full_data.destinations, seed=0) nn_val_rand_sampler = RandEdgeSampler(new_node_val_data.sources, new_node_val_data.destinations, seed=1) test_rand_sampler = RandEdgeSampler(full_data.sources, full_data.destinations, seed=2)