'csv' imported but unused:
2 import csv'sys' imported but unused:
4 import sys'graph_tool' imported but unused:
9 import graph_tool'pandas as pd' imported but unused:
12 import pandas as pd'torch.nn' imported but unused:
15 import torch.nn as nn'torchvision' imported but unused:
16 import torchvisionLine too long (112 > 79 characters):
23 from utils import set_seed, Logger, BatchLogger, log_config, initialize_wandb, close_wandb, ParseKwargs, load, \Line too long (89 > 79 characters):
35 parser.add_argument('-d', '--dataset', choices=gds.supported_datasets, required=True)Line too long (89 > 79 characters):
36 parser.add_argument('-a', '--algorithm', choices=supported.algorithms, required=True)Line too long (108 > 79 characters):
40 help='Convenience parameter that scales all dataset splits down to the specified fraction, 'Line too long (111 > 79 characters):
41 'for development purposes. Note that this also scales the test set down, so the reported 'Line too long (90 > 79 characters):
46 parser.add_argument('--resume', type=parse_bool, const=True, nargs='?', default=False)Line too long (117 > 79 characters):
50 help='Identifies how the train/val/test split is constructed. Choices are dataset-specific.')Line too long (86 > 79 characters):
51 parser.add_argument('--dataset_kwargs', nargs='*', action=ParseKwargs, default={})Line too long (92 > 79 characters):
52 parser.add_argument('--download', default=False, type=parse_bool, const=True, nargs='?',Line too long (105 > 79 characters):
53 help='If true, tries to downloads the dataset if it does not exist in root_dir.')Line too long (85 > 79 characters):
57 parser.add_argument('--loader_kwargs', nargs='*', action=ParseKwargs, default={})Line too long (88 > 79 characters):
59 parser.add_argument('--uniform_over_groups', type=parse_bool, const=True, nargs='?')Line too long (84 > 79 characters):
60 parser.add_argument('--distinct_groups', type=parse_bool, const=True, nargs='?')Line too long (82 > 79 characters):
63 parser.add_argument('--eval_loader', choices=['standard'], default='standard')Line too long (84 > 79 characters):
66 parser.add_argument('--model_kwargs', nargs='*', action=ParseKwargs, default={},Line too long (108 > 79 characters):
67 help='keyword arguments for model initialization passed as key1=value1 key2=value2')Line too long (83 > 79 characters):
71 parser.add_argument('--loss_kwargs', nargs='*', action=ParseKwargs, default={},Line too long (107 > 79 characters):
72 help='keyword arguments for loss initialization passed as key1=value1 key2=value2')Line too long (97 > 79 characters):
90 choices=['cycle_graph', 'path_graph', 'complete_graph', 'binomial_tree'])Line too long (90 > 79 characters):
95 parser.add_argument('--val_metric_decreasing', type=parse_bool, const=True, nargs='?')Line too long (88 > 79 characters):
103 parser.add_argument('--optimizer_kwargs', nargs='*', action=ParseKwargs, default={})Line too long (88 > 79 characters):
107 parser.add_argument('--scheduler_kwargs', nargs='*', action=ParseKwargs, default={})Line too long (92 > 79 characters):
108 parser.add_argument('--scheduler_metric_split', choices=['train', 'val'], default='val')Line too long (93 > 79 characters):
112 parser.add_argument('--eval_only', type=parse_bool, const=True, nargs='?', default=False)Line too long (98 > 79 characters):
113 parser.add_argument('--process_outputs_function', choices=supported.process_outputs_functions)Line too long (102 > 79 characters):
114 parser.add_argument('--evaluate_all_splits', type=parse_bool, const=True, nargs='?', default=True)Line too long (191 > 79 characters):
117 help='If eval_only is set, then eval_epoch allows you to specify evaluating at a particular epoch. By default, it evaluates the best epoch by validation performance.')Line too long (96 > 79 characters):
120 parser.add_argument('--random_split', type=parse_bool, const=True, nargs='?', default=False)Line too long (131 > 79 characters):
125 help='The directory where [dataset]/data can be found (or should be downloaded to, if it does not exist).')Line too long (92 > 79 characters):
129 parser.add_argument('--save_best', type=parse_bool, const=True, nargs='?', default=True)Line too long (92 > 79 characters):
130 parser.add_argument('--save_last', type=parse_bool, const=True, nargs='?', default=True)Line too long (92 > 79 characters):
131 parser.add_argument('--save_pred', type=parse_bool, const=True, nargs='?', default=True)Line too long (85 > 79 characters):
132 parser.add_argument('--no_group_logging', type=parse_bool, const=True, nargs='?')Line too long (93 > 79 characters):
133 parser.add_argument('--use_wandb', type=parse_bool, const=True, nargs='?', default=False)Line too long (96 > 79 characters):
134 parser.add_argument('--progress_bar', type=parse_bool, const=True, nargs='?', default=False)Line too long (110 > 79 characters):
144 if config.algorithm in {'deepCORAL', 'FLAG', 'GCL'} or config.model in {'gin_10_layers', 'cheb'} :Line too long (88 > 79 characters):
145 raise ValueError('For Jiuhai\'s experiments, these are too slow, kill.')Line too long (105 > 79 characters):
154 if (config.algorithm == 'MLDG' or config.algorithm == 'FLAG') and config.dataset != 'SBM-Isolation' :Line too long (116 > 79 characters):
182 config.device = torch.device("cuda:" + str(config.device)) if torch.cuda.is_available() else torch.device("cpu")Line too long (152 > 79 characters):
198 logger = Logger(os.path.join(config.log_dir, f'{config.dataset}_{config.algorithm}_{config.parameter}_{config.model}_seed-{config.seed}.txt'), mode)Line too long (97 > 79 characters):
240 datasets[split]['dataset'] = full_dataset.get_subset(split, frac=config.default_frac)Line too long (81 > 79 characters):
242 datasets[split]['dataset'] = full_dataset.get_subset(split, frac=1.0)Line too long (204 > 79 characters):
269 os.path.join(config.log_dir, f'{config.dataset}_{config.algorithm}_{config.parameter}_{config.model}_seed-{config.seed}_{split}_eval.csv'), mode=mode, use_wandb=(config.use_wandb and verbose))Line too long (204 > 79 characters):
271 os.path.join(config.log_dir, f'{config.dataset}_{config.algorithm}_{config.parameter}_{config.model}_seed-{config.seed}_{split}_algo.csv'), mode=mode, use_wandb=(config.use_wandb and verbose))Line too long (128 > 79 characters):
275 if config.no_group_logging and full_dataset.is_classification and full_dataset.y_size == 1 and full_dataset.n_classes <= 10:Line too long (90 > 79 characters):
300 save_path = model_prefix.with_name(model_prefix.name + 'epoch-last_model.pth')Line too long (84 > 79 characters):
304 for file in os.listdir(config.log_dir) if file.endswith('.pth')]Line too long (109 > 79 characters):
307 save_path = model_prefix.with_name(model_prefix.name + f'epoch-{latest_epoch}_model.pth')Line too long (106 > 79 characters):
311 logger.write(f'Resuming from epoch {epoch_offset} with best val metric {best_val_metric}')Line too long (96 > 79 characters):
330 eval_model_path = model_prefix.with_name(model_prefix.name + 'epoch-best_model.pth')Line too long (112 > 79 characters):
332 eval_model_path = model_prefix.with_name(model_prefix.name + f'epoch-{config.eval_epoch}_model.pth')Too many blank lines (3):
30 def main():Too many blank lines (2):
45 # ResumeToo many blank lines (2):
177 # For the 3wlgnn model, we need to set batch_size to 1Too many blank lines (2):
196 if not os.path.exists(config.log_dir):Too many blank lines (2):
201 # Record configToo many blank lines (2):
286 ## Initialize algorithmToo many blank lines (2):
296 if not config.eval_only: