Пример #1
0
def test0():
    try:
        client = Client(debug=True)
    except IOError:
        raise SkipTest()

    client[:].use_cloudpickle()
    trials = IPythonTrials(client, 'log')

    def simple_objective(args):
        # -- why are these imports here !?
        # -- is it because they need to be imported on the client?
        #
        # Yes, the client namespace is empty, so some imports may be
        # needed here. Errors on the engines can be found by
        # using debug=True when instantiating the Client.
        import hyperopt
        return {'loss': args**2, 'status': hyperopt.STATUS_OK}

    space = hyperopt.hp.uniform('x', 0, 1)

    minval = trials.fmin(simple_objective,
                         space=space,
                         algo=hyperopt.tpe.suggest,
                         max_evals=25,
                         verbose=True)
    print(minval)
    assert minval['x'] < .2
Пример #2
0
def test0():
    client = Client()
    trials = IPythonTrials(client)

    minval = trials.fmin(simple_objective, space, hyperopt.tpe.suggest, 25)
    print minval
    assert minval['x'] < .2
Пример #3
0
def test0():
    client = Client()
    trials = IPythonTrials(client)

    minval = trials.fmin(simple_objective, space, hyperopt.tpe.suggest, 25)
    print minval
    assert minval['x'] < .2
Пример #4
0
def test0():
    try:
        client = Client(debug=True)
    except IOError:
        raise SkipTest()

    client[:].use_dill()
    trials = IPythonTrials(client, 'log')

    def simple_objective(args):
        # -- why are these imports here !?
        # -- is it because they need to be imported on the client?
        #
        # Yes, the client namespace is empty, so some imports may be
        # needed here. Errors on the engines can be found by
        # using debug=True when instantiating the Client.
        import hyperopt
        return {'loss': args ** 2, 'status': hyperopt.STATUS_OK}

    space = hyperopt.hp.uniform('x', 0, 1)

    minval = trials.fmin(simple_objective, space=space,
                         algo=hyperopt.tpe.suggest, max_evals=25, verbose=True)
    print(minval)
    assert minval['x'] < .2
def test0():
    try:
        client = Client()
    except IOError:
        raise SkipTest()
    trials = IPythonTrials(client)

    minval = trials.fmin(simple_objective, space, hyperopt.tpe.suggest, 25)
    print minval
    assert minval['x'] < .2
Пример #6
0
def get_iptrials(filename):
    client = Client()
    try:
        iptrials = cPickle.load(open(filename))
        iptrials._client = client
    except IOError:
        iptrials = IPythonTrials(client)
    except (EOFError, cPickle.PickleError):
        print "ERROR: unpickling FAILED"
        iptrials = IPythonTrials(client)
    return iptrials
Пример #7
0
def test_fmin_fn():
    try:
        client = Client()
    except IOError:
        raise SkipTest()

    client[:].use_cloudpickle()

    trials = IPythonTrials(client, 'log')
    assert not trials._testing_fmin_was_called

    def simple_objective(args):
        import hyperopt
        return {'loss': args**2, 'status': hyperopt.STATUS_OK}

    space = hyperopt.hp.uniform('x', 0, 1)

    minval = hyperopt.fmin(simple_objective,
                           space=space,
                           algo=hyperopt.tpe.suggest,
                           max_evals=25,
                           trials=trials)

    assert minval['x'] < .2
    assert trials._testing_fmin_was_called
Пример #8
0
def test_fmin_fn():
    client = Client()
    trials = IPythonTrials(client)
    assert not trials._testing_fmin_was_called
    minval = hyperopt.fmin(simple_objective,
                           space,
                           algo=hyperopt.tpe.suggest,
                           max_evals=25,
                           trials=trials)

    assert minval['x'] < .2
    assert trials._testing_fmin_was_called