def get_dataset(dataset_name, normalization):
    # Load dataset
    (train_images,
     train_labels), (test_images,
                     test_labels) = datasets.get_dataset(dataset_name)

    # Normalize data
    if normalization == "-1to1":
        train_images, min, max = preprocessing.normalize_minus_one_to_one(
            train_images)
        test_images = preprocessing.normalize_minus_one_to_one(
            test_images, min, max)
    elif normalization == 'gaussian':
        train_images, mean, std = preprocessing.normalize_gaussian(
            train_images)
        test_images = preprocessing.normalize_gaussian(test_images, mean, std)

    return (train_images, train_labels), (test_images, test_labels)
예제 #2
0
    (train_images,
     train_labels), (test_images,
                     test_labels) = datasets.get_dataset(DATASET_NAME)

    if AUX_DATASET_NAME:
        (aux_images, _), _ = datasets.get_dataset(AUX_DATASET_NAME)
        train_images = np.concatenate((train_images, aux_images), axis=0)

    # Normalize data
    if NORMALIZATION == "-1to1":
        train_images, min, max = preprocessing.normalize_minus_one_to_one(
            train_images)
        test_images = preprocessing.normalize_minus_one_to_one(
            test_images, min, max)
    elif NORMALIZATION == 'gaussian':
        train_images, mean, std = preprocessing.normalize_gaussian(
            train_images)
        test_images = preprocessing.normalize_gaussian(test_images, mean, std)

    # Load ensemble models
    ensemble_model_names = saveload.get_ensemble_model_names()
    model_names = ensemble_model_names[ENSEMBLE_LOAD_NAME][DATASET_NAME]
    print(model_names)

    measures = {'endd': defaultdict(list), 'ensm': defaultdict(list)}
    for n_models in N_MODELS_LIST:
        # Get model names
        if SAMPLE_ENSEMBLE_MODELS:
            model_name_subset = np.random.choice(model_names, n_models)
        else:
            model_name_subset = model_names[:n_models]
            #model_name_subset = ['vgg_cifar10_cifar10_25']