コード例 #1
0
template = sampleTemplate(groundgraph, numtemplate)

if 'WORKHASH' in os.environ:
    jobhash = os.environ['WORKHASH']
    if not r.hexists('jobs:grounds', jobhash):
        r.hset('jobs:grounds', jobhash,
               zlib.compress(cPickle.dumps(groundgraph)))

random.seed()
np.random.seed()

datasizes = [4, 16, 32, 64, 128, 256]
temps = [1.0, 1.0, 2.0, 2.0, 5.0, 5.0]

for temperature, numdata in zip(temps, datasizes):
    data = generateData(groundgraph, joint, numdata)
    groundbnet = BayesNetCPD(states, data, limparent=3)
    groundbnet.set_cpds(joint)
    obj = BayesNetCPD(states, data, limparent=3)
    b = BayesNetSampler(obj, template, groundbnet, priorweight)
    s = SAMCRun(b, burn, stepscale, refden, thin)
    s.sample(iters, temperature)
    s.compute_means()

    if 'WORKHASH' in os.environ:
        r.lpush('jobs:done:' + jobhash, s.read_db())
        r.lpush('custom:%s:samplesize=%d' % (jobhash, numdata),
                s.db.root.computed.means._v_attrs['kld'])

    s.db.close()
コード例 #2
0
burn = 1
stepscale=10
temperature = 1.0
thin = 1
refden = 0.0

random.seed(123456)
np.random.seed(123456)

groundgraph = generateTree(N, comps)
data = generateData(groundgraph,numdata)
#template = sampleTemplate(groundgraph, numtemplate)

random.seed()
np.random.seed()

ground = TreeNet(N, graph=groundgraph)
b = TreeNet(N, data=data, ground=ground)
s = SAMCRun(b,burn,stepscale,refden,thin,verbose=True)
s.sample(iters, temperature)

s.compute_means()

# All to exercise cde deps
tmp = s.read_db()
import cPickle
txt = zlib.compress(cPickle.dumps([1,2,3]))

if 'WORKHASH' in os.environ:
    r.lpush('jobs:done:'+os.environ['WORKHASH'], s.read_db())