Skip to content

Conversation

EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented Jan 29, 2025

library(tidymodels)

model <- 
  mlp(activation = tune()) %>%
  set_engine("keras") %>%
  set_mode("classification")

set.seed(1)
res <- tune_grid(
  workflow(class ~ ., model),
  vfold_cv(sim_classification(1000), v = 2),
  grid = 10
)

res |>
  collect_metrics() |>
  count(activation)
#> # A tibble: 10 × 2
#>    activation       n
#>    <chr>        <int>
#>  1 elu              3
#>  2 exponential      3
#>  3 hard_sigmoid     3
#>  4 linear           3
#>  5 selu             3
#>  6 sigmoid          3
#>  7 softmax          3
#>  8 softplus         3
#>  9 swish            3
#> 10 tanh             3

model <- 
  mlp(activation = tune()) %>%
  set_engine("brulee") %>%
  set_mode("classification")

set.seed(1)
res <- tune_grid(
  workflow(class ~ ., model),
  vfold_cv(sim_classification(1000), v = 2),
  grid = 10
)
#> → A | warning: Current loss in NaN. Training wil be stopped.
#> There were issues with some computations   A: x1
#> There were issues with some computations   A: x2
#> There were issues with some computations   A: x2
#> 

res |>
  collect_metrics() |>
  count(activation)
#> # A tibble: 10 × 2
#>    activation      n
#>    <chr>       <int>
#>  1 elu             3
#>  2 hardshrink      3
#>  3 hardtanh        3
#>  4 leaky_relu      3
#>  5 log_sigmoid     3
#>  6 relu6           3
#>  7 selu            3
#>  8 softplus        3
#>  9 softsign        3
#> 10 tanhshrink      3

@EmilHvitfeldt EmilHvitfeldt marked this pull request as draft January 29, 2025 20:07
@EmilHvitfeldt EmilHvitfeldt marked this pull request as ready for review January 29, 2025 22:51
@EmilHvitfeldt EmilHvitfeldt requested a review from topepo January 29, 2025 22:51
@topepo topepo merged commit 9f0ba3f into main Feb 1, 2025
10 checks passed
@topepo topepo deleted the smart-activation-by-engine branch February 1, 2025 14:38
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants