tests/testthat/test-utils.R

testthat::context("Utility functions")

testthat::test_that("softmax", {
  X <- cbind(1, 1)
  testthat::expect_equivalent(softmax(X, ref=FALSE),
                              cbind(.5, .5))
  X <- rnorm(10)
  testthat::expect_equivalent(softmax(X), lava::expit(X))

  X <- cbind(1,2,3)
  testthat::expect_equivalent(softmax(X),
                              exp(c(0,X))/sum(exp(c(0,X))))
})

Try the targeted package in your browser

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

targeted documentation built on Oct. 26, 2022, 1:09 a.m.