コード例 #1
0
def create_observation_dict(suggestion):
    start = time.time()
    accuracy = calculate_objective(
        suggestion.assignments,
        data,
        with_architecture=with_architecture,
    )
    end = time.time()

    failed = True
    values = None
    duration = start - end
    if accuracy > 75 and duration > -250:
        values = [
            {
                'name': 'accuracy',
                'value': accuracy
            },
            {
                'name': 'negative_train_time',
                'value': duration
            },
        ]
        failed = False
    return {
        'suggestion': suggestion.id,
        'values': values,
        'failed': failed,
    }
コード例 #2
0
def create_observation_dict(suggestion):
    start = time.time()
    accuracy = calculate_objective(
        suggestion.assignments,
        data,
        with_architecture=with_architecture,
    )
    end = time.time()
    return {
        'suggestion': suggestion.id,
        'values': [
            {'name': 'accuracy', 'value': accuracy},
            {'name': 'negative_train_time', 'value': start - end},
        ],
    }
コード例 #3
0
    if with_architecture:
        exp_name = 'GPU-powered Sentiment Analysis (SGD + Architecture)'
        param_filepath = 'cnn_text/long_hyperparams.json'
    else:
        exp_name = 'GPU-powered Sentiment Analysis (SGD Only)'
        param_filepath = 'cnn_text/hyperparams.json'

    with open(param_filepath) as f:
        hyperparams = f.read()
        hyperparams = json.loads(hyperparams)

    experiment = conn.experiments().create(name=exp_name,
                                           project='sigopt-examples',
                                           parameters=hyperparams,
                                           observation_budget=40 *
                                           len(hyperparams))

    print("Created experiment: https://sigopt.com/experiment/" + experiment.id)
else:
    experiment = conn.experiments(experiment_id).fetch()

# Optimization Loop
data = get_data()
for _ in range(experiment.observation_budget):
    suggestion = conn.experiments(experiment.id).suggestions().create()
    value = calculate_objective(suggestion.assignments,
                                data,
                                with_architecture=with_architecture)
    observation = conn.experiments(experiment.id).observations().create(
        value=value, suggestion=suggestion.id)