Skip to contents

Classification MLP softmax head (Geron Ch 10, morie.fn grmlc)

Usage

morie_geron_classification_mlp_output(a_last, W_out, b_out)

Arguments

a_last

Last hidden activation (vector or batch).

W_out

(K, hidden) output weights.

b_out

Output bias.

Value

List with probabilities, logits, predicted_class (0-based), max_probability, n_classes.

Examples

morie_geron_classification_mlp_output(matrix(c(1, 2, 0.5, -1),
    2, byrow = TRUE), matrix(c(1, -1, 0.5, 2, 0, 1), 3, byrow = TRUE),
    c(0.1, 0.2, -0.1))
#> $probabilities
#>             [,1]       [,2]       [,3]
#> [1,] 0.003473778 0.93940118 0.05712504
#> [2,] 0.900854122 0.03860352 0.06054236
#> 
#> $logits
#>      [,1]  [,2] [,3]
#> [1,] -0.9  4.70  1.9
#> [2,]  1.6 -1.55 -1.1
#> 
#> $predicted_class
#> [1] 1 0
#> 
#> $max_probability
#> [1] 0.9394012 0.9008541
#> 
#> $n_classes
#> [1] 3
#> 
#> $estimate
#>             [,1]       [,2]       [,3]
#> [1,] 0.003473778 0.93940118 0.05712504
#> [2,] 0.900854122 0.03860352 0.06054236
#> 
#> $n
#> [1] 2
#>