dig.auggraph.method¶
GraphAug¶
An augmentation method for graph datasets under dig.auggraph.method.GraphAug
implemented from the paper
Automated Data Augmentations for Graph Classification.
Runs the training of a graph classification model using the augmented data generated by the already trained generator. |
|
Runs the training of an augmented samples generator model which uses the already trained reward generation model. |
|
Runs the training of a reward generation model which will be able to distinguish between graphs with different labels. |
- class RunnerAugCls(data_root_path, dataset_name, conf)[source]¶
Runs the training of a graph classification model using the augmented data generated by the already trained generator. Check
examples.auggraph.GraphAug.run_aug_cls
for examples on how to run this augmented classifier model.- Parameters
data_root_path (string) – Directory where datasets should be saved.
dataset_name (
dig.auggraph.method.GraphAug.constants.enums.DatasetName
) – Name of the graph dataset.conf (dict) – Hyperparameters for the model. Check
examples.auggraph.GraphAug.conf.aug_cls_conf
for examples on how to define the conf dictionary for the augmented classifier model.
- train_test(out_root_path, log_file='record.txt')[source]¶
This method is used to run the training for the classification model on the augmented graph dataset and then validate the epoch parameters.
- Parameters
out_root_path (string) – Directory where the results of this augmented classifier model will be saved.
log_file (string) – File where training and validation logs are written.
- class RunnerGenerator(data_root_path, dataset_name, conf)[source]¶
Runs the training of an augmented samples generator model which uses the already trained reward generation model. For a given graph, the model generates an augmented sample and a likelihood that this is a label invariant augmentation. This prediction is then evaluated by the reward generation model and a loss is computed based on these metrics. The loss is then minimized through training. Check
examples.auggraph.GraphAug.run_generator
for examples on how to run the generator model.- Parameters
data_root_path (string) – Directory where datasets should be saved.
dataset_name (
dig.auggraph.method.GraphAug.constants.enums.DatasetName
) – Name of the graph dataset.conf (dict) – Hyperparameters for the model. Check
examples.auggraph.GraphAug.conf.generator_conf
for examples on how to define the conf dictionary for the generator.
- class RunnerRewardGen(data_root_path, dataset_name, conf)[source]¶
Runs the training of a reward generation model which will be able to distinguish between graphs with different labels. Check
examples.auggraph.GraphAug.run_reward_gen
for examples on how to run the reward generation model.- Parameters
data_root_path (string) – Directory where datasets should be saved.
dataset_name (
dig.auggraph.method.GraphAug.constants.enums.DatasetName
) – Name of the graph dataset.conf (dict) – Hyperparameters for the model. Check
examples.auggraph.GraphAug.conf.reward_gen_conf
for examples on how to define the conf dictionary for the reward generator.
- train_test(results_path, num_save=30)[source]¶
This method is used to run the training for the reward generation model and validate the epoch parameters.
- Parameters
results_path (string) – Directory where the resulting optimal parameters of the reward generation model will be saved.
num_save (int) – Number of final epochs for which model parameters will be saved.
S-Mixup¶
The S-Mixup from the “Graph Mixup with Soft Alignments” paper.
The S-Mixup from the "Graph Mixup with Soft Alignments" paper. |
- class smixup(data_root_path, dataset, GMNET_conf)[source]¶
The S-Mixup from the “Graph Mixup with Soft Alignments” paper.
- Parameters
data_root_path (string) – Directory where datasets are saved.
dataset (string) – Dataset Name.
conf (dict) – Hyperparameters of the graph matching network which is used to compute the soft alignments.
- train_test(batch_size, cls_model, cls_nlayers, cls_hidden, cls_dropout, cls_lr, cls_epochs, alpha, ckpt_path, sim_method='cos')[source]¶
This method first train a GMNET and then use the GMNET to perform S-Mixup.
- Parameters
batch_size (int) – Batch size of training the classifier.
cls_model (string) – Use GCN or GIN as the backbone of the classifier.
cls_nlayers (int) – Number of GNN layers of the classifier.
cls_hidden (int) – Number of hidden units of the classifier.
cls_dropout (float) – Dropout ratio of the classifier.
cls_lr (float) – Initial learning rate of training the classifier.
cls_epochs (int) – Training epochs of the classifier.
alpha (float) – Mixup ratio.
ckpt_path (string) – Location for saving checkpoints.
sim_method (string) – Similarity function used to compute the assignment matrix. (default:
cos
)