
Depth selection by validation-error plateau (Geron Ch 9, morie.fn hmhplm)
Source:R/geron_w4b_native.R
morie_geron_hidden_layers_heuristic.RdValidation split order comes from the shared LCG stream, not numpy's PCG64 permutation.
Usage
morie_geron_hidden_layers_heuristic(
model,
X,
y,
max_layers = 10,
min_layers = 1,
patience = 2,
tol = 1e-04,
val_fraction = 0.2,
seed = 0
)Value
List with best_n_layers, best_error, errors, depths_tried, stopped_early, estimate, n, method.
Examples
X <- matrix(c(1, 2, 3, 4), ncol = 1)
y <- c(3, 6, 9, 12)
vshape <- function(L, Xt, yt, Xv, yv) abs(L - 3) + 0.5
morie_geron_hidden_layers_heuristic(vshape, X, y, max_layers = 10,
patience = 2)
#> $best_n_layers
#> [1] 3
#>
#> $best_error
#> [1] 0.5
#>
#> $errors
#> $errors$`1`
#> [1] 2.5
#>
#> $errors$`2`
#> [1] 1.5
#>
#> $errors$`3`
#> [1] 0.5
#>
#> $errors$`4`
#> [1] 1.5
#>
#> $errors$`5`
#> [1] 2.5
#>
#>
#> $depths_tried
#> [1] 5
#>
#> $stopped_early
#> [1] TRUE
#>
#> $estimate
#> [1] 0.5
#>
#> $n
#> [1] 4
#>
#> $method
#> [1] "Depth selection by validation-error plateau"
#>