Skip to content

Commit

Permalink
numerically stable softmax
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymoudiki committed Nov 29, 2024
1 parent e4bab01 commit 429c8f7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2,533 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: learningmachine
Type: Package
Title: Machine Learning with Explanations and Uncertainty Quantification
Version: 2.7.1
Date: 2024-11-11
Version: 2.7.2
Date: 2024-11-29
Author: T. Moudiki
Maintainer: T. Moudiki <[email protected]>
Description: Regression-based Machine Learning with explanations and uncertainty quantification.
Expand Down Expand Up @@ -32,3 +32,4 @@ Suggests:
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
Config/testthat/edition: 3
Remotes: thierrymoudiki/bayesianrvfl
5 changes: 3 additions & 2 deletions R/utils_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ create_new_predictors <- function(x, nb_hidden = 5,
}
g <- switch(match.arg(activ),
"relu" = function(x) x*(x>0),
"sigmoid" = function(x) 1/(1 + exp(-x)),
"sigmoid" = function(x) (1/(1 + exp(-x)))*(x >= 0) + (exp(x)/(1 + exp(x)))*(x < 0),
"tanh" = function(x) tanh(x),
"leakyrelu" = function(x) x*(x > 0) + 0.01*x*(x <= 0),
"elu" = function(x) x*(x >= 0) + 0.01*(exp(x)-1)*(x < 0),
Expand Down Expand Up @@ -205,7 +205,8 @@ get_classes_idx <- function(new_probs, q_threshold, level) {

# get expit probs -----
expit_probs <- function(x) {
temp <- 1 / (1 + exp(-x))
temp <- (1 / (1 + exp(-x)))*(x >= 0)
temp <- temp + (exp(x)/(1 + exp(x)))*(x < 0)
return(sweep(x=temp, MARGIN=1, FUN="/",
STATS=rowSums(temp)))
}
Expand Down
8 changes: 8 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.onLoad <- function(libname, pkgname){
if (!requireNamespace("devtools", quietly = TRUE)) {
utils::install.packages("devtools")
}
if (!requireNamespace("bayesianrvfl", quietly = TRUE)) {
devtools::install_github("thierrymoudiki/bayesianrvfl")
}
}
Loading

0 comments on commit 429c8f7

Please sign in to comment.