Skip to content

Commit b27150d

Browse files
committed
Improve grid search
1 parent 4a79c7a commit b27150d

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

tutorials/deeplearning/deeplearning.R

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,21 @@ plot(m)
110110

111111

112112
## Grid search
113-
if (FALSE) {
114-
g <- list()
115-
g$activation <- c("Rectifier", "Maxout")
113+
if (TRUE) {
116114
numlayers <- sample(2:5,1)
117-
g$hidden <- list(rep(sample(200:1000,1),2), rep(sample(100:200,1),3), rep(sample(30:100,1),4))
118-
g$l1 <- c(0, runif(sample(1:3),0,1e-3))
119-
g$l2 <- c(0, runif(sample(1:3),0,1e-3))
120-
g$input_dropout_ratio <- c(0,runif(2, 0, 0.1))
121-
print(g)
122-
123115
hyper_params <- list(
124-
activation = g$activation,
125-
hidden = g$hidden,
126-
l1 = g$l1,
127-
l2 = g$l2,
128-
input_dropout_ratio = g$input_dropout_ratio
116+
activation = c("Rectifier"),
117+
hidden = list(rep(sample(200:1000,1),2), rep(sample(100:200,1),3), rep(sample(30:100,1),4)),
118+
l1 = c(0, runif(sample(1:3),0,1e-3)),
119+
l2 = c(0, runif(sample(1:3),0,1e-3)),
120+
input_dropout_ratio = c(0,runif(2, 0, 0.1)),
121+
rate=runif(sample(3:5),0.002,0.02),
122+
rate_annealing=10^runif(sample(3:6),1,3)*1e-8,
123+
momentum_start=runif(sample(3:5),0,0.5),
124+
momentum_stable =runif(sample(3:5),0.5,0.999),
125+
momentum_ramp = runif(sample(3),0,100)*1e6
129126
)
127+
hyper_params
130128

131129
h2o.grid(
132130
"deeplearning",
@@ -135,6 +133,14 @@ if (FALSE) {
135133
validation_frame = valid,
136134
x=predictors,
137135
y=response,
136+
epochs=1000,
137+
stopping_metric="logloss",
138+
stopping_tolerance=1e-2, ## stop when logloss does not improve by >=1% for 2 scoring events
139+
stopping_rounds=2,
140+
score_validation_samples=10000, ## downsample validation set for faster scoring
141+
score_duty_cycle=0.025, ## don't score more than 2.5% of the wall time
142+
adaptive_rate=F, ## manually tuned learning rate
143+
max_w2 = 10, ## helps stability for Rectifier
138144
hyper_params = hyper_params
139145
)
140146
}

0 commit comments

Comments
 (0)