@@ -20,14 +20,28 @@ task_list = mlr3misc::pmap(cc18_small, function(data_id, name, NumberOfFeatures,
20
20
task_list
21
21
22
22
# define the learners
23
+ neurons = function (n_layers , latent_dim ) {
24
+ rep(latent_dim , n_layers )
25
+ }
26
+
27
+ n_layers_values <- 1 : 10
28
+ latent_dim_values <- seq(10 , 500 , by = 10 )
29
+ neurons_search_space <- mapply(
30
+ neurons ,
31
+ expand.grid(n_layers = n_layers_values , latent_dim = latent_dim_values )$ n_layers ,
32
+ expand.grid(n_layers = n_layers_values , latent_dim = latent_dim_values )$ latent_dim ,
33
+ SIMPLIFY = FALSE
34
+ )
35
+
23
36
mlp = lrn(" classif.mlp" ,
24
37
activation = nn_relu ,
25
- neurons = to_tune(ps(
26
- n_layers = p_int(lower = 1 , upper = 10 ), latent = p_int(10 , 500 ),
27
- .extra_trafo = function (x , param_set ) {
28
- list (neurons = rep(x $ latent , x $ n_layers ))
29
- })
30
- ),
38
+ # neurons = to_tune(ps(
39
+ # n_layers = p_int(lower = 1, upper = 10), latent = p_int(10, 500),
40
+ # .extra_trafo = function(x, param_set) {
41
+ # list(neurons = rep(x$latent, x$n_layers))
42
+ # })
43
+ # ),
44
+ neurons = to_tune(neurons_search_space ),
31
45
batch_size = to_tune(c(16 , 32 , 64 , 128 , 256 )),
32
46
p = to_tune(0.1 , 0.9 ),
33
47
epochs = to_tune(upper = 1000L , internal = TRUE ),
@@ -37,7 +51,7 @@ mlp = lrn("classif.mlp",
37
51
device = " cpu"
38
52
)
39
53
40
- # define the optimizatio nstrategy
54
+ # define the optimization strategy
41
55
bayesopt_ego = mlr_loop_functions $ get(" bayesopt_ego" )
42
56
surrogate = srlrn(lrn(" regr.km" , covtype = " matern5_2" ,
43
57
optim.method = " BFGS" , control = list (trace = FALSE )))
@@ -54,19 +68,20 @@ tnr_mbo = tnr("mbo",
54
68
# define an AutoTuner that wraps the classif.mlp
55
69
at = auto_tuner(
56
70
learner = mlp ,
57
- tuner = tnr( " grid_search " ) ,
71
+ tuner = tnr_mbo ,
58
72
resampling = rsmp(" cv" ),
59
73
measure = msr(" classif.acc" ),
60
- term_evals = 1000
74
+ term_evals = 10
61
75
)
62
76
63
- future :: plan(" multisession" , workers = 8 )
77
+ future :: plan(" multisession" , workers = 64 )
64
78
65
79
lrn_rf = lrn(" classif.ranger" )
66
80
design = benchmark_grid(
67
81
task_list ,
68
82
learners = list (at , lrn_rf ),
69
- resampling = rsmp(" cv" , folds = 10 ))
83
+ resampling = rsmp(" cv" , folds = 10 )
84
+ )
70
85
71
86
time = bench :: system_time(
72
87
bmr <- benchmark(design )
@@ -75,4 +90,4 @@ time = bench::system_time(
75
90
bmrdt = as.data.table(bmr )
76
91
77
92
fwrite(bmrdt , here(" R" , " rf_use_case" , " results" , " bmrdt.csv" ))
78
- fwrite(time , here(" R" , " rf_use_case" , " results" , " time.csv" ))
93
+ fwrite(time , here(" R" , " rf_use_case" , " results" , " time.csv" ))
0 commit comments