-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckpoint.py
More file actions
46 lines (35 loc) · 1.29 KB
/
Copy pathcheckpoint.py
File metadata and controls
46 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import urllib.request
from urllib.error import HTTPError, URLError
import pytorch_lightning as pl
import numpy as np
import torch
checkpoint_path = "checkpoint_path"
data_path = "./data_path"
base_url = "https://raw.githubusercontent.com/phlippe/saved_models/main/tutorial7/"
pretrained_filename = [
"NodeLevelMLP.ckpt",
"NodeLevelGNN.ckpt",
"GraphLevelGraphConv.ckpt",
]
def configure_seed(seed:int = 42):
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
pl.seed_everything(seed)
os.makedirs(checkpoint_path, exist_ok = True)
def download_pretrained_files(url = base_url, files = pretrained_filename):
for file in files:
file_path = os.path.join(checkpoint_path, file)
url_path = url + file
os.makedirs(os.path.dirname(file_path), exist_ok = True)
if not os.path.isfile(file_path):
print(f"downloading this url_path files {url_path}")
try:
urllib.request.urlretrieve(url_path, file_path)
except HTTPError as e:
print("downloading this files from the github link or rather from my google drive")
if __name__ == "__main__":
download_pretrained_files()