コード例 #1
0
def test_load_pth():
    """"Testing the model load functionality"""
    model_name = "Test_CPU"
    device = 'cpu'
    path = "Results/Pths/Univariate/"
    model = model_load(model_name=model_name, device=device, path=path)

    assert isinstance(model, LSTM)
コード例 #2
0
def test_evaluate():
    data_X = rand(500, 132, 1)
    data_y = rand(500, 1)
    device = 'cpu'

    model = model_load("Test_CPU", device, path="Results/Pths/Univariate/")
    model.device = device
    model.to(device)

    learning = DeepLearning(model=model,
                            data_X=data_X,
                            data_y=data_y,
                            optimiser=Adam(model.parameters()))

    learning.train_val_test()
    learning.create_data_loaders()
    assert learning.evaluate(learning.model, learning.test_loader) < 1e6
コード例 #3
0
def test_mtl():
    """Check that an output is obtained for MTL model"""
    data_X = rand(100, 132, 7)
    data_y = rand(100, 5)
    device = 'cpu'

    model = model_load("Test_MTL_CPU", device, path="Results/Pths/MTL/")
    model.device = device
    model.to(device)

    learning = DeepLearning(model=model,
                            data_X=data_X,
                            data_y=data_y,
                            optimiser=Adam(model.parameters()),
                            n_epochs=1,
                            debug=False)

    learning.train_val_test()
    learning.create_data_loaders()
    learning.training_wrapper()
    assert learning.best_val_score < np.inf
コード例 #4
0
def test_validate():
    """Check that an output is obtained for single task mode;"""
    data_X = rand(10, 132, 1)
    data_y = rand(10, 1)
    device = 'cpu'

    model = model_load("Test_CPU", device, path="Results/Pths/Univariate/")
    model.device = device
    model.to(device)

    learning = DeepLearning(model=model,
                            data_X=data_X,
                            data_y=data_y,
                            optimiser=Adam(model.parameters()),
                            n_epochs=1,
                            disp_freq=1e6,
                            fig_disp_freq=1e6)

    learning.train_val_test()
    learning.training_wrapper()
    assert learning.best_val_score < np.inf
コード例 #5
0
def test_train_val_test():
    """"Checking that the deeplearning class splits
    the data correctly"""
    model_name = "Test_CPU"
    device = 'cpu'
    path = "Results/Pths/Univariate/"

    model = model_load(model_name=model_name, device=device, path=path)

    data_X = rand(100, 20, 5)
    data_y = rand(100, 5)

    learning = DeepLearning(model=model,
                            data_X=data_X,
                            data_y=data_y,
                            optimiser=Adam(model.parameters()))

    learning.train_val_test()

    assert list(learning.X_train.shape) == [60, 20, 5]
    assert list(learning.X_val.size()) == [20, 20, 5]
    assert list(learning.X_test.shape) == [20, 20, 5]