Exemplo n.º 1
0
def eval_grid_point(learner, name, t, cp, verbosity):
    structure = learner
    learner = {'dag':dag.run, 'tree':tree.run}[structure]
    rs = random.getstate(), np.random.get_state()
    start = time.time()
    net, vld_llh, tst_llh = learner(name, t, cp, verbosity=verbosity)
    elapsed = time.time() - start
    result = {'name':name, 't':t, 'cp':cp, 'time':elapsed, 'num_nodes':len(net.pot), 'num_edges':net.num_edges, \
              'vld_llh':vld_llh, 'tst_llh':tst_llh, 'spn':network.to_data(net), 'random_state':rs, 'structure':structure}
    return result
Exemplo n.º 2
0
Arquivo: learn.py Projeto: awd4/spnss
def save_net(net, filename, prompt=False):
    if filename is not None:
        if prompt:
            ri = raw_input('Keep this SPN? ')
            if ri.lower() not in ['y', 'yes']:
                return
        print 'saving...'
        spn = network.to_data(net)
        with open(filename, 'wb') as fp:
            pickle.dump(spn, fp)