Exemple #1
0
def test_bayesian_searcher(_, _1):
    train_data, test_data = get_processed_data()
    clean_dir(default_test_path)
    generator = BayesianSearcher(3, (28, 28, 3), verbose=False, path=default_test_path)
    Constant.N_NEIGHBOURS = 1
    Constant.T_MIN = 0.8
    for _ in range(2):
        generator.search(train_data, test_data)
    clean_dir(default_test_path)
    assert len(generator.history) == 2
Exemple #2
0
def test_max_acq(_, _1):
    train_data, test_data = get_processed_data()
    clean_dir(default_test_path)
    Constant.N_NEIGHBOURS = 2
    Constant.SEARCH_MAX_ITER = 0
    Constant.T_MIN = 0.8
    Constant.BETA = 1
    generator = BayesianSearcher(3, (28, 28, 3), verbose=False, path=default_test_path)
    for _ in range(3):
        generator.search(train_data, test_data)
    for index1, descriptor1 in enumerate(generator.descriptors):
        for descriptor2 in generator.descriptors[index1 + 1:]:
            assert edit_distance(descriptor1, descriptor2, 1) != 0

    clean_dir(default_test_path)
Exemple #3
0
def test_export_json(_, _1):
    train_data, test_data = get_processed_data()

    clean_dir(default_test_path)
    generator = BayesianSearcher(3, (28, 28, 3), verbose=False, path=default_test_path)
    Constant.N_NEIGHBOURS = 1
    Constant.T_MIN = 0.8
    for _ in range(3):
        generator.search(train_data, test_data)
    file_path = os.path.join(default_test_path, 'test.json')
    generator.export_json(file_path)
    import json
    data = json.load(open(file_path, 'r'))
    assert len(data['networks']) == 3
    assert len(data['tree']['children']) == 2
    clean_dir(default_test_path)
    assert len(generator.history) == 3
Exemple #4
0
def test_model_trainer():
    model = DefaultClassifierGenerator(3,
                                       (28, 28, 3)).generate().produce_model()
    train_data, test_data = get_processed_data()
    ModelTrainer(model, train_data, test_data, Accuracy,
                 False).train_model(max_iter_num=3)