R/lrelu.R

Defines functions dlReLU lReLU

Documented in dlReLU lReLU

#' Leaky ReLU activation function
#'
#' @param x numeric vector
#' @return numeric vector
#' @family Activation Functions
#' @export
#' @examples
#'
#' lReLU(c(-1, 0, 1))
#'
#' \donttest{
#' # Can use in rxode2 as well
#'
#' r <- rxode2({r <- lReLU(time)})
#' e <- et(c(-1, 0, 1))
#' rxSolve(r, e)
#' }
lReLU <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 5L)
}

#' Derivative of Leaky ReLU activation function
#'
#' @param x numeric vector
#' @return numeric vector
#' @family Activation Functions
#' @export
#' @examples
#'
#' dlReLU(c(-1, 0, 1))
#'
#' \donttest{
#' # Can use in rxode2 as well
#'
#' r <- rxode2({r <- dlReLU(time)})
#' e <- et(c(-1, 0, 1))
#' rxSolve(r, e)
#' }
#'
dlReLU <- function(x) {
  checkmate::assertNumeric(x, finite=TRUE, any.missing=FALSE)
  .Call(`_rxode2_activationF`, x, 8L)
}

Try the rxode2 package in your browser

Any scripts or data that you put into this service are public.

rxode2 documentation built on July 28, 2026, 5:08 p.m.