|
61 | 61 | os.makedirs(file_path.rsplit("/", 1)[0], exist_ok=True) |
62 | 62 | if not os.path.isfile(file_path): |
63 | 63 | file_url = base_url + file_name |
64 | | - print("Downloading %s..." % file_url) |
| 64 | + print(f"Downloading {file_url}...") |
65 | 65 | try: |
66 | 66 | urllib.request.urlretrieve(file_url, file_path) |
67 | 67 | except HTTPError as e: |
@@ -616,7 +616,7 @@ def forward(self, data, mode="train"): |
616 | 616 | elif mode == "test": |
617 | 617 | mask = data.test_mask |
618 | 618 | else: |
619 | | - assert False, "Unknown forward mode: %s" % mode |
| 619 | + assert False, f"Unknown forward mode: {mode}" |
620 | 620 |
|
621 | 621 | loss = self.loss_module(x[mask], data.y[mask]) |
622 | 622 | acc = (x[mask].argmax(dim=-1) == data.y[mask]).sum().float() / mask.sum() |
@@ -671,7 +671,7 @@ def train_node_classifier(model_name, dataset, **model_kwargs): |
671 | 671 | trainer.logger._default_hp_metric = None # Optional logging argument that we don't need |
672 | 672 |
|
673 | 673 | # Check whether pretrained model exists. If yes, load it and skip training |
674 | | - pretrained_filename = os.path.join(CHECKPOINT_PATH, "NodeLevel%s.ckpt" % model_name) |
| 674 | + pretrained_filename = os.path.join(CHECKPOINT_PATH, f"NodeLevel{model_name}.ckpt") |
675 | 675 | if os.path.isfile(pretrained_filename): |
676 | 676 | print("Found pretrained model, loading...") |
677 | 677 | model = NodeLevelGNN.load_from_checkpoint(pretrained_filename) |
@@ -790,7 +790,7 @@ def print_results(result_dict): |
790 | 790 | # %% |
791 | 791 | print("Data object:", tu_dataset.data) |
792 | 792 | print("Length:", len(tu_dataset)) |
793 | | -print("Average label: %4.2f" % (tu_dataset.data.y.float().mean().item())) |
| 793 | +print(f"Average label: {tu_dataset.data.y.float().mean().item():4.2f}") |
794 | 794 |
|
795 | 795 | # %% [markdown] |
796 | 796 | # The first line shows how the dataset stores different graphs. |
@@ -957,7 +957,7 @@ def train_graph_classifier(model_name, **model_kwargs): |
957 | 957 | trainer.logger._default_hp_metric = None |
958 | 958 |
|
959 | 959 | # Check whether pretrained model exists. If yes, load it and skip training |
960 | | - pretrained_filename = os.path.join(CHECKPOINT_PATH, "GraphLevel%s.ckpt" % model_name) |
| 960 | + pretrained_filename = os.path.join(CHECKPOINT_PATH, f"GraphLevel{model_name}.ckpt") |
961 | 961 | if os.path.isfile(pretrained_filename): |
962 | 962 | print("Found pretrained model, loading...") |
963 | 963 | model = GraphLevelGNN.load_from_checkpoint(pretrained_filename) |
|
0 commit comments