예제 #1
0
파일: grid_search.py 프로젝트: awd4/spnss
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
예제 #2
0
파일: learn.py 프로젝트: 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)