-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathtest_notebooks_gpu.py
123 lines (104 loc) · 3.23 KB
/
test_notebooks_gpu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Copyright (c) Recommenders contributors.
# Licensed under the MIT License.
import os
import pytest
import papermill as pm
from recommenders.utils.gpu_utils import get_number_gpus
@pytest.mark.notebooks
@pytest.mark.gpu
def test_gpu_vm():
assert get_number_gpus() >= 1
@pytest.mark.notebooks
@pytest.mark.gpu
def test_fastai(notebooks, output_notebook, kernel_name):
notebook_path = notebooks["fastai"]
pm.execute_notebook(
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(TOP_K=10, MOVIELENS_DATA_SIZE="mock100", EPOCHS=1),
)
@pytest.mark.notebooks
@pytest.mark.gpu
def test_ncf(notebooks, output_notebook, kernel_name):
notebook_path = notebooks["ncf"]
pm.execute_notebook(
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(
TOP_K=10, MOVIELENS_DATA_SIZE="mock100", EPOCHS=1, BATCH_SIZE=1024
),
)
@pytest.mark.notebooks
@pytest.mark.gpu
def test_ncf_deep_dive(notebooks, output_notebook, kernel_name):
notebook_path = notebooks["ncf_deep_dive"]
pm.execute_notebook(
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(
TOP_K=10, MOVIELENS_DATA_SIZE="mock100", EPOCHS=1, BATCH_SIZE=2048
),
)
@pytest.mark.notebooks
@pytest.mark.gpu
def test_xdeepfm(notebooks, output_notebook, kernel_name):
notebook_path = notebooks["xdeepfm_quickstart"]
pm.execute_notebook(
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(
EPOCHS_FOR_SYNTHETIC_RUN=1,
EPOCHS_FOR_CRITEO_RUN=1,
BATCH_SIZE_SYNTHETIC=128,
BATCH_SIZE_CRITEO=512,
),
)
@pytest.mark.notebooks
@pytest.mark.gpu
def test_wide_deep(notebooks, output_notebook, kernel_name, tmp):
notebook_path = notebooks["wide_deep"]
# Simple test (train only 1 batch == 1 step)
model_dir = os.path.join(tmp, "wide_deep_0")
os.mkdir(model_dir)
params = {
"MOVIELENS_DATA_SIZE": "mock100",
"STEPS": 1,
"EVALUATE_WHILE_TRAINING": False,
"MODEL_DIR": model_dir,
"EXPORT_DIR_BASE": model_dir,
"RATING_METRICS": ["rmse"],
"RANKING_METRICS": ["ndcg_at_k"],
}
pm.execute_notebook(
notebook_path, output_notebook, kernel_name=kernel_name, parameters=params
)
# Test with different parameters
model_dir = os.path.join(tmp, "wide_deep_1")
os.mkdir(model_dir)
params = {
"MOVIELENS_DATA_SIZE": "mock100",
"STEPS": 1,
"ITEM_FEAT_COL": None,
"EVALUATE_WHILE_TRAINING": True,
"MODEL_DIR": model_dir,
"EXPORT_DIR_BASE": model_dir,
"RATING_METRICS": ["rsquared"],
"RANKING_METRICS": ["map_at_k"],
}
pm.execute_notebook(
notebook_path, output_notebook, kernel_name=kernel_name, parameters=params
)
@pytest.mark.notebooks
@pytest.mark.gpu
def test_dkn_quickstart(notebooks, output_notebook, kernel_name):
notebook_path = notebooks["dkn_quickstart"]
pm.execute_notebook(
notebook_path,
output_notebook,
kernel_name=kernel_name,
parameters=dict(EPOCHS=1, BATCH_SIZE=500),
)