def arg_parse(): parser = argparse.ArgumentParser(description="GraphPool arguments.") io_parser = parser.add_mutually_exclusive_group(required=False) io_parser.add_argument("--dataset", dest="dataset", help="Input dataset.") benchmark_parser = io_parser.add_argument_group() benchmark_parser.add_argument("--bmname", dest="bmname", help="Name of the benchmark dataset") io_parser.add_argument("--pkl", dest="pkl_fname", help="Name of the pkl data file") softpool_parser = parser.add_argument_group() softpool_parser.add_argument( "--assign-ratio", dest="assign_ratio", type=float, help="ratio of number of nodes in consecutive layers", ) softpool_parser.add_argument("--num-pool", dest="num_pool", type=int, help="number of pooling layers") parser.add_argument( "--linkpred", dest="linkpred", action="store_const", const=True, default=False, help="Whether link prediction side objective is used", ) parser_utils.parse_optimizer(parser) parser.add_argument("--datadir", dest="datadir", help="Directory where benchmark is located") parser.add_argument("--logdir", dest="logdir", help="Tensorboard log directory") parser.add_argument("--ckptdir", dest="ckptdir", help="Model checkpoint directory") parser.add_argument("--cuda", dest="cuda", help="CUDA.") parser.add_argument( "--gpu", dest="gpu", action="store_const", const=True, default=False, help="whether to use GPU.", ) parser.add_argument( "--max-nodes", dest="max_nodes", type=int, help= "Maximum number of nodes (ignore graghs with nodes exceeding the number.", ) parser.add_argument("--batch-size", dest="batch_size", type=int, help="Batch size.") parser.add_argument("--epochs", dest="num_epochs", type=int, help="Number of epochs to train.") parser.add_argument( "--train-ratio", dest="train_ratio", type=float, help="Ratio of number of graphs training set to all graphs.", ) parser.add_argument( "--num_workers", dest="num_workers", type=int, help="Number of workers to load data.", ) parser.add_argument( "--feature", dest="feature_type", help="Feature used for encoder. Can be: id, deg", ) parser.add_argument("--input-dim", dest="input_dim", type=int, help="Input feature dimension") parser.add_argument("--hidden-dim", dest="hidden_dim", type=int, help="Hidden dimension") parser.add_argument("--output-dim", dest="output_dim", type=int, help="Output dimension") parser.add_argument("--num-classes", dest="num_classes", type=int, help="Number of label classes") parser.add_argument( "--num-gc-layers", dest="num_gc_layers", type=int, help="Number of graph convolution layers before each pooling", ) parser.add_argument( "--bn", dest="bn", action="store_const", const=True, default=False, help="Whether batch normalization is used", ) parser.add_argument("--dropout", dest="dropout", type=float, help="Dropout rate.") parser.add_argument( "--nobias", dest="bias", action="store_const", const=False, default=True, help="Whether to add bias. Default to True.", ) parser.add_argument( "--weight-decay", dest="weight_decay", type=float, help="Weight decay regularization constant.", ) parser.add_argument("--method", dest="method", help="Method. Possible values: base, ") parser.add_argument("--name-suffix", dest="name_suffix", help="suffix added to the output filename") parser.set_defaults( datadir="data", # io_parser logdir="log", ckptdir="ckpt", dataset="syn1", opt="adam", # opt_parser opt_scheduler="none", max_nodes=100, cuda="1", feature_type="default", lr=0.001, clip=2.0, batch_size=20, num_epochs=1000, train_ratio=0.8, test_ratio=0.1, num_workers=1, input_dim=10, hidden_dim=20, output_dim=20, num_classes=2, num_gc_layers=3, dropout=0.0, weight_decay=0.005, method="base", name_suffix="", assign_ratio=0.1, ) return parser.parse_args()
def arg_parse(): parser = argparse.ArgumentParser(description="GNN Explainer arguments.") io_parser = parser.add_mutually_exclusive_group(required=False) io_parser.add_argument("--dataset", dest="dataset", help="Input dataset.") benchmark_parser = io_parser.add_argument_group() benchmark_parser.add_argument("--bmname", dest="bmname", help="Name of the benchmark dataset") io_parser.add_argument("--pkl", dest="pkl_fname", help="Name of the pkl data file") parser_utils.parse_optimizer(parser) parser.add_argument( "--clean-log", action="store_true", help="If true, cleans the specified log directory before running.") parser.add_argument("--logdir", dest="logdir", help="Tensorboard log directory") parser.add_argument("--ckptdir", dest="ckptdir", help="Model checkpoint directory") parser.add_argument("--cuda", dest="cuda", help="CUDA.") parser.add_argument( "--gpu", dest="gpu", action="store_const", const=True, default=False, help="whether to use GPU.", ) parser.add_argument("--epochs", dest="num_epochs", type=int, help="Number of epochs to train.") parser.add_argument("--hidden-dim", dest="hidden_dim", type=int, help="Hidden dimension") parser.add_argument("--output-dim", dest="output_dim", type=int, help="Output dimension") parser.add_argument( "--num-gc-layers", dest="num_gc_layers", type=int, help="Number of graph convolution layers before each pooling", ) parser.add_argument( "--bn", dest="bn", action="store_const", const=True, default=False, help="Whether batch normalization is used", ) parser.add_argument("--dropout", dest="dropout", type=float, help="Dropout rate.") parser.add_argument( "--nobias", dest="bias", action="store_const", const=False, default=True, help="Whether to add bias. Default to True.", ) parser.add_argument( "--no-writer", dest="writer", action="store_const", const=False, default=True, help="Whether to add bias. Default to True.", ) # Explainer parser.add_argument("--mask-act", dest="mask_act", type=str, help="sigmoid, ReLU.") parser.add_argument( "--mask-bias", dest="mask_bias", action="store_const", const=True, default=False, help="Whether to add bias. Default to True.", ) parser.add_argument("--explain-node", dest="explain_node", type=int, help="Node to explain.") parser.add_argument("--graph-idx", dest="graph_idx", type=int, help="Graph to explain.") parser.add_argument( "--graph-mode", dest="graph_mode", action="store_const", const=True, default=False, help="whether to run Explainer on Graph Classification task.", ) parser.add_argument( "--multigraph-class", dest="multigraph_class", type=int, help= "whether to run Explainer on multiple Graphs from the Classification task for examples in the same class.", ) parser.add_argument( "--multinode-class", dest="multinode_class", type=int, help= "whether to run Explainer on multiple nodes from the Classification task for examples in the same class.", ) parser.add_argument( "--align-steps", dest="align_steps", type=int, help="Number of iterations to find P, the alignment matrix.", ) parser.add_argument("--method", dest="method", type=str, help="Method. Possible values: base, att.") parser.add_argument("--name-suffix", dest="name_suffix", help="suffix added to the output filename") parser.add_argument( "--explainer-suffix", dest="explainer_suffix", help="suffix added to the explainer log", ) parser.add_argument( "--hops", dest="hops", type=int, help="k-hop subgraph considered for GraphSHAP", ) parser.add_argument( "--num_samples", dest="num_samples", type=int, help="number of samples used to train GraphSHAP", ) parser.add_argument( "--multiclass", type=bool, help='False if we consider explanations for the predicted class only') parser.add_argument( "--hv", type=str, help="way simplified input is translated to the original input space") parser.add_argument("--feat", type=str, help="node features considered for hv above") parser.add_argument("--coal", type=str, help="type of coalition sampler") parser.add_argument("--g", type=str, help="method used to train g on derived dataset") parser.add_argument( "--regu", type=int, help='None if we do not apply regularisation, 1 if only feat') parser.add_argument("--info", type=bool, help='True if we want to see info about the explainer') parser.add_argument( "--fullempty", type=str, default=None, help='True if want to discard full and empty coalitions') parser.add_argument( "--S", type=int, default=3, help= 'Max size of coalitions sampled in priority and treated specifically') # TODO: Check argument usage parser.set_defaults( logdir="log", ckptdir="ckpt", dataset="syn1", #bmname='Mutagenicity', graph_mode=False, opt="adam", opt_scheduler="none", gpu=False, cuda="0", lr=0.1, clip=2.0, batch_size=20, num_epochs=150, hidden_dim=20, output_dim=20, num_gc_layers=3, dropout=0.0, method="base", name_suffix="", explainer_suffix="", align_steps=100, explain_node=None, graph_idx=-1, mask_act="sigmoid", multigraph_class=-1, multinode_class=-1, hops=2, num_samples=65, multiclass=False, fullempty=None, S=1, hv='compute_pred', feat='Expectation', coal='SmarterSeparate', g='WLR_sklearn', regu=None, info=True, ) return parser.parse_args()
def arg_parse(): print("Attempt to parse arguments...") parser = argparse.ArgumentParser(description='GNN program arguments.') # Set optimizer parameters parser_utils.parse_optimizer(parser) ## Add parsing arguments parser.add_argument('--datadir', dest='datadir', help='Directory where benchmark is located') parser.add_argument('--logdir', dest='logdir', help='Tensorboard log directory') parser.add_argument('--ckptdir', dest='ckptdir', help='Model checkpoint directory') # dataset is set by defaults below # opt and opt_scheduler defined in parse_optimizer parser.add_argument( '--max_nodes', dest='max_nodes', type=int, help= 'Maximum number of nodes (ignore graphs with nodes exceeding the number.' ) parser.add_argument('--cuda', dest='cuda', help='CUDA.') parser.add_argument('--feature', dest='feature_type', help='Feature used for encoder. Can be : id, deg') # lr and clip defined in parse_optimizer parser.add_argument('--batch_size', dest='batch_size', type=int, help='Batch size.') parser.add_argument('--epochs', dest='num_epochs', type=int, help='Number of epochs to train.') parser.add_argument( '--train_ratio', dest='train_ratio', type=float, help='Ratio of number of graphs training set to all graphs.') # test_ratio is set by defaults below parser.add_argument('--num_workers', dest='num_workers', type=int, help='Number of workers to load data.') parser.add_argument('--input_dim', dest='input_dim', type=int, help='Input feature dimension') # Cannot use "parse_prog.py --h" causes "error: ambiguous" (Usage: parse_prog.py --hidden_dim=30) parser.add_argument('--hidden_dim', dest='hidden_dim', type=int, help='Hidden dimension') parser.add_argument('--output_dim', dest='output_dim', type=int, help='Output dimension') parser.add_argument('--num_classes', dest='num_classes', type=int, help='Number of label classes') parser.add_argument( '--num_gc_layers', dest='num_gc_layers', type=int, help='Number of graph convolution layers before each pooling') parser.add_argument('--dropout', dest='dropout', type=float, help='Dropout rate.') parser.add_argument('--weight_decay', dest='weight_decay', type=float, help='Weight decay regularization constant.') parser.add_argument('--method', dest='method', help='Method. Possible values: base, ') parser.add_argument('--name-suffix', dest='name_suffix', help='suffix added to the output filename') # assign_ratio is set by defaults below parser.add_argument('--nobias', dest='bias', action='store_const', const=False, default=True, help='Whether to add bias. Default to True.') parser.add_argument('--gpu', dest='gpu', action='store_const', const=True, default=False, help='Whether to use GPU.') parser.add_argument('--linkpred', dest='linkpred', action='store_const', const=True, default=False, help='Whether link prediction side objective is used') parser.add_argument('--bn', dest='bn', action='store_const', const=True, default=False, help='Whether batch normalization is used') # bmname is set by defaults below # Set defaults for all program parameters unless provided by user parser.set_defaults( datadir="data", # Directory where benchmark is stored (io_parser) logdir="log", # Tensorboard log directory ckptdir="ckpt", # Model checkpoint directory dataset="BAGraph", # Synthetic dataset, syn1 opt="adam", # Opt parser opt_scheduler="none", # Optimizer scheduler max_nodes=100, # Maximum number of nodes # (ignore graphs with nodes exceeding the number) cuda="0", # CUDA value feature_type= "default", # Feature used for encoder with possible values : id, deg lr=0.001, # Learning rate clip=2.0, # Gradient clipping batch_size=20, # Batch size num_epochs=1000, # Number of epochs to train data train_ratio=0.8, # Ratio of number of training set to all graphs test_ratio=0.1, num_workers=1, # Number of workers to load data input_dim=10, # Input feature dimension hidden_dim=20, # Hidden layer dimension output_dim=20, # Output layer dimension num_classes=2, # Number of label classes num_gc_layers= 3, # Number of graph convolution layers before each pooling dropout=0.0, # Dropout rate weight_decay=0.005, # Weight decay regularization constant method="base", # Method used with possible values : base name_suffix="", # Suffix added to the output filename assign_ratio=0.1, # Ratio of number of nodes in consecutive layers bias=True, # "Whether to add bias gpu=False, # Whether to use GPU linkpred=False, # Whether link prediction side objective is used bn=False, # Whether batch normalization is used bmname=None) # Name of the benchmark datase return parser.parse_args()
def arg_parse(): parser = argparse.ArgumentParser(description="GNN Explainer arguments.") io_parser = parser.add_mutually_exclusive_group(required=False) io_parser.add_argument("--dataset", dest="dataset", help="Input dataset.") benchmark_parser = io_parser.add_argument_group() benchmark_parser.add_argument("--bmname", dest="bmname", help="Name of the benchmark dataset") io_parser.add_argument("--pkl", dest="pkl_fname", help="Name of the pkl data file") parser_utils.parse_optimizer(parser) parser.add_argument( "--clean-log", action="store_true", help="If true, cleans the specified log directory before running.") parser.add_argument("--logdir", dest="logdir", help="Tensorboard log directory") parser.add_argument("--ckptdir", dest="ckptdir", help="Model checkpoint directory") parser.add_argument("--cuda", dest="cuda", help="CUDA.") parser.add_argument( "--gpu", dest="gpu", action="store_const", const=True, default=False, help="whether to use GPU.", ) parser.add_argument("--epochs", dest="num_epochs", type=int, help="Number of epochs to train.") parser.add_argument("--hidden-dim", dest="hidden_dim", type=int, help="Hidden dimension") parser.add_argument("--output-dim", dest="output_dim", type=int, help="Output dimension") parser.add_argument( "--num-gc-layers", dest="num_gc_layers", type=int, help="Number of graph convolution layers before each pooling", ) parser.add_argument( "--bn", dest="bn", action="store_const", const=True, default=False, help="Whether batch normalization is used", ) parser.add_argument("--dropout", dest="dropout", type=float, help="Dropout rate.") parser.add_argument( "--nobias", dest="bias", action="store_const", const=False, default=True, help="Whether to add bias. Default to True.", ) parser.add_argument( "--no-writer", dest="writer", action="store_const", const=False, default=True, help="Whether to add bias. Default to True.", ) # Explainer parser.add_argument("--mask-act", dest="mask_act", type=str, help="sigmoid, ReLU.") parser.add_argument( "--mask-bias", dest="mask_bias", action="store_const", const=True, default=False, help="Whether to add bias. Default to True.", ) parser.add_argument("--explain-node", dest="explain_node", type=int, help="Node to explain.") parser.add_argument("--graph-idx", dest="graph_idx", type=int, help="Graph to explain.") parser.add_argument( "--graph-mode", dest="graph_mode", action="store_const", const=True, default=False, help="whether to run Explainer on Graph Classification task.", ) parser.add_argument( "--multigraph-class", dest="multigraph_class", type=int, help= "whether to run Explainer on multiple Graphs from the Classification task for examples in the same class.", ) parser.add_argument( "--multinode-class", dest="multinode_class", type=int, help= "whether to run Explainer on multiple nodes from the Classification task for examples in the same class.", ) parser.add_argument( "--align-steps", dest="align_steps", type=int, help="Number of iterations to find P, the alignment matrix.", ) parser.add_argument("--method", dest="method", type=str, help="Method. Possible values: base, att.") parser.add_argument("--name-suffix", dest="name_suffix", help="suffix added to the output filename") parser.add_argument( "--explainer-suffix", dest="explainer_suffix", help="suffix added to the explainer log", ) # TODO: Check argument usage parser.set_defaults( logdir="log", ckptdir="ckpt", dataset="sat1", opt="adam", opt_scheduler="none", cuda="0", lr=0.1, clip=2.0, batch_size=20, num_epochs=100, hidden_dim=20, output_dim=20, num_gc_layers=3, dropout=0.0, method="base", name_suffix="", explainer_suffix="", align_steps=1000, explain_node=None, graph_idx=-1, mask_act="sigmoid", multigraph_class=-1, multinode_class=-1, ) return parser.parse_args()
def arg_parse(): parser = argparse.ArgumentParser(description='GraphPool arguments.') io_parser = parser.add_mutually_exclusive_group(required=False) io_parser.add_argument('--dataset', dest='dataset', help='Input dataset.') benchmark_parser = io_parser.add_argument_group() benchmark_parser.add_argument('--bmname', dest='bmname', help='Name of the benchmark dataset') io_parser.add_argument('--pkl', dest='pkl_fname', help='Name of the pkl data file') softpool_parser = parser.add_argument_group() softpool_parser.add_argument( '--assign-ratio', dest='assign_ratio', type=float, help='ratio of number of nodes in consecutive layers') softpool_parser.add_argument('--num-pool', dest='num_pool', type=int, help='number of pooling layers') parser.add_argument('--linkpred', dest='linkpred', action='store_const', const=True, default=False, help='Whether link prediction side objective is used') parser_utils.parse_optimizer(parser) parser.add_argument('--datadir', dest='datadir', help='Directory where benchmark is located') parser.add_argument('--logdir', dest='logdir', help='Tensorboard log directory') parser.add_argument('--ckptdir', dest='ckptdir', help='Model checkpoint directory') parser.add_argument('--cuda', dest='cuda', help='CUDA.') parser.add_argument('--gpu', dest='gpu', action='store_const', const=True, default=False, help='whether to use GPU.') parser.add_argument( '--max_nodes', dest='max_nodes', type=int, help= 'Maximum number of nodes (ignore graghs with nodes exceeding the number.' ) parser.add_argument('--batch_size', dest='batch_size', type=int, help='Batch size.') parser.add_argument('--epochs', dest='num_epochs', type=int, help='Number of epochs to train.') parser.add_argument( '--train_ratio', dest='train_ratio', type=float, help='Ratio of number of graphs training set to all graphs.') parser.add_argument('--num_workers', dest='num_workers', type=int, help='Number of workers to load data.') parser.add_argument('--feature', dest='feature_type', help='Feature used for encoder. Can be: id, deg') parser.add_argument('--input_dim', dest='input_dim', type=int, help='Input feature dimension') parser.add_argument('--hidden_dim', dest='hidden_dim', type=int, help='Hidden dimension') parser.add_argument('--output_dim', dest='output_dim', type=int, help='Output dimension') parser.add_argument('--num_classes', dest='num_classes', type=int, help='Number of label classes') parser.add_argument( '--num_gc_layers', dest='num_gc_layers', type=int, help='Number of graph convolution layers before each pooling') parser.add_argument('--bn', dest='bn', action='store_const', const=True, default=False, help='Whether batch normalization is used') parser.add_argument('--dropout', dest='dropout', type=float, help='Dropout rate.') parser.add_argument('--nobias', dest='bias', action='store_const', const=False, default=True, help='Whether to add bias. Default to True.') parser.add_argument('--weight_decay', dest='weight_decay', type=float, help='Weight decay regularization constant.') parser.add_argument('--method', dest='method', help='Method. Possible values: base, ') parser.add_argument('--name-suffix', dest='name_suffix', help='suffix added to the output filename') parser.set_defaults( datadir='data', # io_parser logdir='log', ckptdir='ckpt', dataset='syn1', opt='adam', # opt_parser opt_scheduler='none', max_nodes=100, cuda='1', feature_type='default', lr=0.0005, clip=2.0, batch_size=20, num_epochs=1000, train_ratio=0.8, test_ratio=0.1, num_workers=1, input_dim=342, hidden_dim=20, output_dim=20, num_classes=4, num_gc_layers=10, dropout=0.0, weight_decay=0.005, method='base', name_suffix='', assign_ratio=0.1, ) return parser.parse_args()
def arg_parse(): print("Attempt to parse arguments for GNN Explainer ...") parser = argparse.ArgumentParser(description='GNN program arguments.') # Set optimizer parameters parser_utils.parse_optimizer(parser) ## Add parsing arguments parser.add_argument('--logdir', dest='logdir', help='Tensorboard log directory') parser.add_argument('--ckptdir', dest='ckptdir', help='Model checkpoint directory') # dataset is set by defaults below # opt and opt_scheduler defined in parse_optimizer parser.add_argument("--cuda", dest="cuda", help="CUDA.") # lr and clip defined in parse_optimizer parser.add_argument('--batch_size', dest='batch_size', type=int, help='Batch size.') parser.add_argument('--epochs', dest='num_epochs', type=int, help='Number of epochs to train.') # Cannot use "parse_prog.py --h" causes "error: ambiguous" (Usage: parse_prog.py --hidden_dim=30) parser.add_argument('--hidden_dim', dest='hidden_dim', type=int, help='Hidden dimension') parser.add_argument('--output_dim', dest='output_dim', type=int, help='Output dimension') parser.add_argument('--num_classes', dest='num_classes', type=int, help='Number of label classes') parser.add_argument('--num_gc_layers', dest='num_gc_layers', type=int, help='Number of graph convolution layers before each pooling') parser.add_argument('--dropout', dest='dropout', type=float, help='Dropout rate.') parser.add_argument('--method', dest='method', help='Method. Possible values: base, att.') parser.add_argument('--name-suffix', dest='name_suffix', help='suffix added to the output filename') parser.add_argument('--nobias', dest='bias', action='store_const', const=False, default=True, help='Whether to add bias. Default to True.') parser.add_argument('--gpu', dest='gpu', action='store_const', const=True, default=False, help='Whether to use GPU.') parser.add_argument('--bn', dest='bn', action='store_const', const=True, default=False, help='Whether batch normalization is used') # bmname is set by defaults below parser.add_argument("--no-writer", dest="writer", action="store_const", const=False, default=True, help="Whether to add bias. Default to True.") # Parameters for Explainer parser.add_argument("--mask-act", dest="mask_act", type=str, help="sigmoid, ReLU.") parser.add_argument("--mask-bias", dest="mask_bias", action="store_const", const=True, default=False, help="Whether to add bias. Default to True.") parser.add_argument("--explain-node", dest="explain_node", type=int, help="Node to explain.") parser.add_argument("--graph-idx", dest="graph_idx", type=int, help="Graph to explain.") parser.add_argument("--graph-mode", dest="graph_mode", action="store_const", const=True, default=False, help="Whether to run Explainer on Graph Classification task.") parser.add_argument("--multigraph-class", dest="multigraph_class", type=int, help="Whether to run Explainer on multiple Graphs from the Classification task for examples in the same class.") parser.add_argument("--multinode-class", dest="multinode_class", type=int, help="whether to run Explainer on multiple nodes from the Classification task for examples in the same class.") parser.add_argument("--explainer-suffix", dest="explainer_suffix", help="suffix added to the explainer log") # Set defaults for all program parameters unless provided by user parser.set_defaults(logdir = "log", # Tensorboard log directory ckptdir = "ckpt", # Model checkpoint directory dataset = "BAGraph", # Synthetic dataset, syn1 opt = "adam", # Opt parser opt_scheduler = "none", # Optimizer scheduler cuda = "0", # CUDA value lr = 0.1, # Learning rate (train : 0.001) clip = 2.0, # Gradient clipping batch_size = 20, # Batch size num_epochs = 100, # Number of epochs for explainer training (train : 1000) hidden_dim = 20, # Hidden layer dimension output_dim = 20, # Output layer dimension num_classes = 2, # Number of label classes num_gc_layers = 3, # Number of graph convolution layers before each pooling dropout = 0.0, # Dropout rate method = "base", # Method used with possible values : base name_suffix = "", # Suffix added to the output filename bias = True, # "Whether to add bias gpu = False, # Whether to use GPU bn = False, # Whether batch normalization is used bmname = None, # Name of the benchmark datase explainer_suffix="", # Suffix added to the explainer log explain_node = 25, # Node to explain (eg. Check is on None) graph_idx = -1, # Graph to explain mask_act="sigmoid", # Type of activation for mask (sigmoid, ReLU) multigraph_class = -1, # Whether to run Explainer on multiple Graphs from the Classification task for examples in the same class multinode_class=-1) # Whether to run Explainer on multiple nodes from the Classification task for examples in the same class return parser.parse_args()