Exemplo n.º 1
0
def get_data(PICKLEDIC, PICKLENAME):

    # read test data
    test_set = load(os.path.join(PICKLEDIC, PICKLENAME))
    if test_set is None:
        print("No Test data, aborting...")
        sys.exit(0)

    random.shuffle(test_set)  # should be here

    with open("../dataset/kFoldDataset/pickles/classes.json") as classesFile:
        class_dict = json.load(classesFile)

    test_lens = get_class_numbers(test_set, class_dict)
    test_data = get_reduced_set(test_set, test_lens, 'min')

    rawdata, specdata, _ = get_samples_and_labels(test_data)

    return rawdata, specdata
Exemplo n.º 2
0
    # read train data
    test_set = load(test_dataset_path)
    if test_set is None:
        print("No Test data, aborting...")
        sys.exit(0)

    random.shuffle(train_set)
    random.shuffle(test_set)  # should be here

    train_lens = get_class_numbers(train_set, class_dict)
    train_data = get_reduced_set(train_set, train_lens, 'min')

    test_lens = get_class_numbers(test_set, class_dict)
    test_data = get_reduced_set(test_set, test_lens, 'min')

    _, Xtrain, Ytrain = get_samples_and_labels(train_data)
    _, Xtest, Ytest = get_samples_and_labels(test_data)

    print("Train size", len(Ytrain))
    print("Test size", len(Ytest))

    Xtrain = tf.convert_to_tensor(Xtrain, dtype=tf.float32)
    Ytrain = tf.convert_to_tensor(Ytrain, dtype=tf.float32)
    Xtest = tf.convert_to_tensor(Xtest, dtype=tf.float32)
    Ytest = tf.convert_to_tensor(Ytest, dtype=tf.float32)

    print("Allocating tensors")

    train_it = tf.data.Dataset.from_tensor_slices((Xtrain, Ytrain))
    test_it = tf.data.Dataset.from_tensor_slices((Xtest, Ytest))
Exemplo n.º 3
0
        test_dataset_path = test_path + str(i)
        raw_path = os.path.join(model_raw, str(i) + '.h5')
        spectro_path = os.path.join(model_spectro, str(i) + '.h5')

        # read test data
        test_set = load(test_dataset_path)
        if test_set is None:
            print("No Test data, aborting...")
            sys.exit(0)

        random.shuffle(test_set)  # should be here

        test_lens = get_class_numbers(test_set, class_dict)
        test_data = get_reduced_set(test_set, test_lens, 'min')

        Xtest_raw, Xtest_spec, Ytest = get_samples_and_labels(test_data)

        size = len(Ytest)

        Xtest_raw = tf.convert_to_tensor(Xtest_raw, dtype=tf.float32)
        Xtest_spec = tf.convert_to_tensor(Xtest_spec, dtype=tf.float32)
        Ytest = tf.convert_to_tensor(Ytest, dtype=tf.float32)

        print("Allocating tensors")

        test_it = tf.data.Dataset.from_tensor_slices(
            (Xtest_raw, Xtest_spec, Ytest))

        rawnet = rawCNN()
        spectronet = SpectroCNN()