Exemplo n.º 1
0
 def __init__(self, model):
     model.eval()
     self.model = model
     self.correct = 0
     class Stat:
         def __init__(self, d, dnm):
             self.domain = d
             self.name = dnm
             self.width = 0
             self.max_eps = 0
             self.safe = 0
             self.proved = 0
             self.time = 0
     self.domains = [ Stat(h.parseValues(domains,d), h.catStrs(d)) for d in args.test_domain ]
Exemplo n.º 2
0
    nets += [(net, net_create)]

    print("Name: ", net_create.__name__)
    print("Number of Neurons (relus): ", net.neuronCount())
    print("Number of Parameters: ",
          sum([h.product(s.size()) for s in net.parameters()]))
    print("Depth (relu layers): ", net.depth())
    print()
    net.showNet()
    print()

if args.domain == []:
    models = [createModel(net, goals.Box(args.width), "Box") for net in nets]
else:
    models = h.flat([[
        createModel(net, h.parseValues(d, goals, scheduling), h.catStrs(d))
        for net in nets
    ] for d in args.domain])

patience = 30
last_best_origin = 0
best_origin = 1e10
last_best = 0
best = 1e10
decay = True
with h.mopen(args.dont_write, os.path.join(out_dir, "log.txt"), "w") as f:
    startTime = timer()
    for epoch in range(1, args.epochs + 1):
        if f is not None:
            f.flush()
        if (epoch - 1) % args.test_freq == 0 and (epoch > 1
Exemplo n.º 3
0
    m = getattr(models,n)
    net_create = (lambda m: lambda: buildNet(m))(m) # why doesn't python do scoping right?  This is a thunk.  It is bad.
    net_create.__name__ = n
    net = buildNet(m)
    net.__name__ = n
    nets += [ (net, net_create) ]

    print("Name: ", net_create.__name__)
    print("Number of Neurons (relus): ", net.neuronCount())
    print("Number of Parameters: ", sum([h.product(s.size()) for s in net.parameters()]))
    print()


if args.domain == []:
    models = [ createModel(net, domains.Box(args.width), "Box") for net in nets]
else:
    models = h.flat([[createModel(net, h.parseValues(domains,d), h.catStrs(d)) for net in nets] for d in args.domain])


with h.mopen(args.dont_write, os.path.join(out_dir, "log.txt"), "w") as f:
    startTime = timer()
    for epoch in range(1, args.epochs + 1):
        if (epoch - 1) % args.test_freq == 0:
            with Timer("test before epoch "+str(epoch),"sample", 10000):
                test(models, epoch, f)
        h.printBoth("Elapsed-Time: {:.2f}s\n".format(timer() - startTime), f = f)
        if args.epochs <= args.test_freq:
            break
        with Timer("train","sample", 60000):
            train(epoch, models)