Exemple #1
0
def test_create_dataset():
    train, val, test = prepare_train_test()
    X, y = create_dataset(train[0:2])
    _, accuracy = model.evaluate([testX, testX, testX],
                                 testy,
                                 batch_size=batch_size,
                                 verbose=0)

    return accuracy


if __name__ == '__main__':
    # data_dir = Path(r'../data/physionet_sleep/eeg_fpz_cz').resolve()
    data_dir = Path(r'../../data/physionet_sleep/eeg_fpz_cz').resolve()
    train, val, test = prepare_train_test(data_dir=data_dir)
    print(len(train))
    from pysleep.data.data_generator import DataGenerator

    X, y = create_dataset(train[0:3])
    val_X, val_y = create_dataset(val[0:1])
    # train_dl = DataGenerator(train[0:3])
    # evaluate_model(X, y, val_X, val_y)

    if 1:
        # model = CNN1Head(model_name='CNN1Head_train3_test2', epochs=20, learning_rate=0.005, batch_size=32)
        model = CNN3Head(model_name='CNN3Head_train10_test0',
                         epochs=25,
                         learning_rate=0.001,
                         batch_size=16,
                         metric='accuracy')
        model.build_model()
        # hist = model.fit_model(train_dl)
        hist = model.fit_model(X, y, val_X,
                               val_y)  # validation_data=(val_X,val_y))