-
Notifications
You must be signed in to change notification settings - Fork 1
/
re_observe_cascade.py
32 lines (24 loc) · 947 Bytes
/
re_observe_cascade.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
import pickle as pkl
import os
from cascade_generator import observe_cascade
from helpers import cascade_source
from glob import glob
graph = 'grqc'
from_obs = 0.1
model = 'si'
from_dir = 'cascade-weighted/{}-m{}-s0.02-o{}/'.format(graph, model, from_obs)
target_obs_list = [0.2, 0.3, 0.4, 0.5]
for target_obs in target_obs_list:
print('target_obs', target_obs)
to_dir = 'cascade-weighted/{}-m{}-s0.02-o{}/'.format(graph, model, target_obs)
if not os.path.exists(to_dir):
os.makedirs(to_dir)
for input_path in glob(from_dir + '*'):
# print('input_path', input_path)
id_ = os.path.basename(input_path)
_, c = pkl.load(open(input_path, 'rb'))[:2]
s = cascade_source(c)
obs = observe_cascade(c, s, target_obs, 'uniform')
output_path = to_dir + id_
# print('output_path', output_path)
pkl.dump((obs, c, None), open(output_path, 'wb'))