-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrun_continual.py
66 lines (47 loc) · 1.72 KB
/
run_continual.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
import autograd.numpy as np
import argparse
import json
from json_parser import parse
from solver.lib_solvers import *
def add_solver(args, spec):
solver = dict()
assert args.algorithm == 'continual'
solver['algorithm'] = args.algorithm
spec['solver'] = solver
def add_dataset(args, spec):
assertion = dict()
assertion['dataset'] = args.dataset
spec['assert'] = assertion
def main():
np.set_printoptions(threshold=20)
parser = argparse.ArgumentParser(description='nSolver')
parser.add_argument('--dataset', type=str, default='none',
help='the chosen algorithm')
parser.add_argument('--algorithm', type=str, default='continual',
help='the chosen algorithm')
args = parser.parse_args()
models = []
if args.dataset == 'acasxu':
base = 'benchmark/reluplex/specs/prop1/prop1_nnet_'
for i in range(1,6):
sub_models = []
for j in range(1,10):
args.spec = base + str(i) + '_' + str(j) + '.json'
with open(args.spec, 'r') as f:
spec = json.load(f)
add_solver(args, spec)
add_dataset(args, spec)
model, assertion, solver, display = parse(spec)
sub_models.append(model)
models.append(sub_models)
solver.solve(models, assertion)
elif args.dataset == 'mnist' or args.dataset == 'cifar10' or args.dataset == 'census':
spec = dict()
add_solver(args, spec)
add_dataset(args, spec)
model, assertion, solver, display = parse(spec)
solver.solve(models, assertion)
else:
assert False
if __name__ == '__main__':
main()