This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_graphs.py
111 lines (92 loc) · 3.36 KB
/
create_graphs.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from util import create_graph
from tqdm import tqdm
import pickle
from train import run_mapper, get_args
from coolname import generate_slug
from torch.utils.tensorboard import SummaryWriter
# create rand graphs and save into file for benchmark
def create_graphs():
lnode = [10, 15, 20, 30, 40]
graphs = {}
for nnodes in tqdm(lnode):
graphs[nnodes] = []
for samples in range(100):
graphdef = create_graph(None, numnodes = nnodes)
graphs[nnodes].append(graphdef)
with open("graphs.pkl","wb") as file:
pickle.dump(graphs, file)
def ex_topoorder():
args = get_args() # Holds all the input arguments
args.epochs = 500000
args.device_topology = [16, 6]
args.nnmode = 'ff_gnn_attention'
with open("graphs_new2.pkl", "rb") as file:
dataset = pickle.load(file)
results = {}
num_node = 15
results[num_node] = {'time':[], 'reward':[]}
time, reward = run_mapper(args, dataset[num_node][0])
results[num_node]['time'].append(time)
results[num_node]['reward'].append(reward)
save = "results"+str(num_node)+".pkl"
with open(save,"wb") as file:
pickle.dump(results, file)
def ex_scale_nodes():
args = get_args() # Holds all the input arguments
args.quiet = True
args.epochs = 50000
args.device_topology = [64, 6]
args.nnmode = 'simple_ff'
with open("graphs_new2.pkl", "rb") as file:
dataset = pickle.load(file)
results = {}
num_nodes = [10, 15, 20, 30, 40]
for num_node in tqdm(num_nodes):
results[num_node] = {'time':[], 'reward':[]}
for i in range(0, 5):
time, reward = run_mapper(args, dataset[num_node][i])
results[num_node]['time'].append(time)
results[num_node]['reward'].append(reward)
save = "results_"+str(num_node)+".pkl"
with open(save,"wb") as file:
pickle.dump(results, file)
def ex_curriculum_rl():
writer = SummaryWriter(comment=f'_{generate_slug(2)}')
print(f'[INFO] Saving log data to {writer.log_dir}')
writer.add_text('experiment config', 'ex_curriculum_rl')
writer.flush()
with open("graphs_new2.pkl", "rb") as file:
dataset = pickle.load(file)
args = get_args() # Holds all the input arguments
args.epochs = 20000
args.device_topology = [16, 6]
args.nnmode = 'ff_gnn_attention'
num_node = 10
run_mapper(args, dataset[num_node], writer)
args = get_args() # Holds all the input arguments
args.epochs = 20000
args.device_topology = [16, 6]
args.nnmode = 'ff_gnn_attention'
args.model = 'model_epoch.pth'
num_node = 15
run_mapper(args, dataset[num_node], writer)
args = get_args() # Holds all the input arguments
args.epochs = 50000
args.device_topology = [16, 6]
args.nnmode = 'ff_gnn_attention'
args.model = 'model_epoch.pth'
num_node = 20
run_mapper(args, dataset[num_node], writer)
args = get_args() # Holds all the input arguments
args.epochs = 100000
args.device_topology = [16, 6]
args.nnmode = 'ff_gnn_attention'
args.model = 'model_epoch.pth'
num_node = 30
results = {}
results[num_node] = {'time': [], 'reward': []}
time, reward = run_mapper(args, dataset[num_node], writer)
results[num_node]['time'].append(time)
results[num_node]['reward'].append(reward)
if __name__ == "__main__":
ex_topoorder()