Skip to content

Commit

Permalink
remove mlp activation check for #1019
Browse files Browse the repository at this point in the history
  • Loading branch information
‘topepo’ committed Feb 14, 2024
1 parent 25fc2c6 commit 6abd185
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions R/mlp.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#' @param activation A single character string denoting the type of relationship
#' between the original predictors and the hidden unit layer. The activation
#' function between the hidden and output layers is automatically set to either
#' "linear" or "softmax" depending on the type of outcome. Possible values are:
#' "linear", "softmax", "relu", and "elu"
#' "linear" or "softmax" depending on the type of outcome. Possible values
#' depend on the engine being used.
#'
#' @templateVar modeltype mlp
#' @template spec-details
Expand Down Expand Up @@ -142,24 +142,6 @@ check_args.mlp <- function(object) {
if (args$dropout > 0 & args$penalty > 0)
rlang::abort("Both weight decay and dropout should not be specified.")


if (object$engine == "brulee") {
act_funs <- c("linear", "relu", "elu", "tanh")
} else if (object$engine == "keras") {
act_funs <- c("linear", "softmax", "relu", "elu")
} else if (object$engine == "h2o") {
act_funs <- c("relu", "tanh")
}

if (is.character(args$activation)) {
if (!any(args$activation %in% c(act_funs))) {
rlang::abort(
glue::glue("`activation` should be one of: ",
glue::glue_collapse(glue::glue("'{act_funs}'"), sep = ", "))
)
}
}

invisible(object)
}

Expand Down Expand Up @@ -210,6 +192,9 @@ keras_mlp <-
seeds = sample.int(10^5, size = 3),
...) {

act_funs <- c("linear", "softmax", "relu", "elu")
rlang::arg_match(activation, act_funs,)

if (penalty > 0 & dropout > 0) {
rlang::abort("Please use either dropoput or weight decay.", call. = FALSE)
}
Expand Down

0 comments on commit 6abd185

Please sign in to comment.