alpha_t = 0.5 log((1 - err)/err); w <- w exp(-alpha y f(x)), renormalised. Default weak learner is a weighted 1-split stump.
Examples
W1 <- matrix(c(1, -1), 1, 2)
W2 <- matrix(c(2, 3), 2, 1)
morie_geron_backpropagation(matrix(c(1, 2), ncol = 1), matrix(c(0,
1), ncol = 1), list(W1, W2), c("relu", "identity"))
#> $grads_W
#> $grads_W[[1]]
#> [,1] [,2]
#> [1,] 16 0
#>
#> $grads_W[[2]]
#> [,1]
#> [1,] 8
#> [2,] 0
#>
#>
#> $grads_b
#> $grads_b[[1]]
#> [1] 10 0
#>
#> $grads_b[[2]]
#> [1] 5
#>
#>
#> $deltas
#> $deltas[[1]]
#> [,1] [,2]
#> [1,] 4 0
#> [2,] 6 0
#>
#> $deltas[[2]]
#> [,1]
#> [1,] 2
#> [2,] 3
#>
#>
#> $loss
#> [1] 6.5
#>
#> $output
#> [,1]
#> [1,] 2
#> [2,] 4
#>
#> $activations_out
#> $activations_out[[1]]
#> [,1]
#> [1,] 1
#> [2,] 2
#>
#> $activations_out[[2]]
#> [,1] [,2]
#> [1,] 1 0
#> [2,] 2 0
#>
#> $activations_out[[3]]
#> [,1]
#> [1,] 2
#> [2,] 4
#>
#>
#> $pre_activations
#> $pre_activations[[1]]
#> [,1] [,2]
#> [1,] 1 -1
#> [2,] 2 -2
#>
#> $pre_activations[[2]]
#> [,1]
#> [1,] 2
#> [2,] 4
#>
#>
#> $estimate
#> [1] 6.5
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "Backpropagation of the mse loss through 2 layers"
#>
morie_geron_adaboost(X = W2, y = W1)
#> $alphas
#> [1] 11.51293 11.51293 11.51293 11.51293 11.51293 11.51293 11.51293 11.51293
#> [9] 11.51293 11.51293
#>
#> $errors
#> [1] 0 0 0 0 0 0 0 0 0 0
#>
#> $train_errors
#> [1] 0 0 0 0 0 0 0 0 0 0
#>
#> $predict
#> function (Xnew)
#> {
#> Bm <- if (is.matrix(Xnew))
#> Xnew
#> else matrix(as.numeric(Xnew), ncol = ncol(A))
#> s <- numeric(nrow(Bm))
#> for (i in seq_along(predictors)) s <- s + alphas[i] * as.numeric(predictors[[i]](Bm))
#> ifelse(s >= 0, classes[2], classes[1])
#> }
#> <environment: 0x562178b18d10>
#>
#> $decision
#> [1] 115.1293 -115.1293
#>
#> $margin
#> [1] 1 1
#>
#> $weights
#> [1] 0.5 0.5
#>
#> $classes
#> [1] -1 1
#>
#> $estimate
#> [1] 0
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "Discrete AdaBoost with reweighted weak learners"
#>
