예제 #1
0
파일: test_gdist.py 프로젝트: cyip/hyperopt
def test_no_redundant_unions():
    s = """{"p0" : uniform(0, 1), "p1": gaussian(0, 1),
    "p2":choice([1, this.p0]), "p3":choice([2, this.p1])}"""
    template = gd.gDist(s)
    idxs, vals, s_N = template.theano_sampler(123)
    for v in theano.gof.graph.ancestors(idxs):
        assert v.owner is None or not isinstance(v.owner.op, gd.SetOp)
예제 #2
0
파일: test_gdist.py 프로젝트: cyip/hyperopt
def pickle_helper(s):
    #pickle_helper_len(s)

    template = gd.gDist(s)

    template2 = cPickle.loads(cPickle.dumps(template, protocol=1))

    assert template.sample(5) == template2.sample(5)

    idxs, vals, s_N = template.theano_sampler(5)
    idxs2, vals2, s_N2 = template.theano_sampler(5)
    len(idxs) == len(idxs2)
    len(vals) == len(vals2)

    if len(template.flatten()) != len(template2.flatten()):
        tf1 = template.flatten()
        tf2 = template2.flatten()
        for i in range(max(len(tf1), len(tf1))):
            print '----'
            print i
            if i < len(tf1):
                print tf1[i]
            else:
                print 'N/A'
            if i < len(tf2):
                print tf2[i]
            else:
                print 'N/A'
        raise WrongLen()

    if len(template.random_nodes()) != len(template2.random_nodes()):
        raise WrongRandomLen()

    assert template == template2
예제 #3
0
파일: test_gdist.py 프로젝트: cyip/hyperopt
def base_func(s, length, names, random_types, idxs, vals, res):
    template = gd.gDist(s)

    random_nodes = template.random_nodes()

    assert len(random_nodes) == length
    assert template.flatten_names() == names
    assert [node.__class__.__name__ for node in random_nodes] == random_types
    assert res == template.idxs_vals_to_dict_list(idxs, vals)