This function applies the Rectified Linear Unit (ReLU) activation function to the input numeric vector. The ReLU function is defined as the positive part of its argument: \(f(x) = max(0, x)\).
Examples
ReLU(c(-1, 0, 1, 2))
#> [1] 0 0 1 2
# Can also be used in rxode2:
x <- rxode2({
r=ReLU(time)
})
#>
#>
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
e <- et(c(-1, 0, 1, 2))
rxSolve(x, e)
#> ── Solved rxode2 object ──
#> ── Parameters (value$params): ──
#> # A tibble: 1 × 0
#> ── Initial Conditions (value$inits): ──
#> named numeric(0)
#> ── First part of data (object): ──
#> # A tibble: 4 × 2
#> time r
#> <dbl> <dbl>
#> 1 -1 0
#> 2 0 0
#> 3 1 1
#> 4 2 2