Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark/rf use case #294

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from
Draft

Benchmark/rf use case #294

wants to merge 39 commits into from

Conversation

cxzhang4
Copy link
Collaborator

No description provided.

library(data.table)
library(tidytable)

cc18_collection = ocl(99)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cc18_collection = ocl(99)
options(mlr3oml.cache = TRUE)
cc18_collection = ocl(99)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also add this to your .Rprofile


library(here)

# define the tasks
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsk("oml", task_id = 1067)
similarly hard-code for every task

this will ignore the OpenML resampling

# define the learners
mlp = lrn("classif.mlp",
activation = nn_relu,
neurons = to_tune(
Copy link
Member

@sebffischer sebffischer Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
neurons = to_tune(
neurons = to_tune(ps(n_layers = p_int(lower = 1, upper = 10), latent = p_int(10, 500), .extra_trafo = function(x, param_set) {
list(neurons = rep(x$latent, x$n_layers))
}))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't work because the libraries don't allow parameter transformations. When I try to run the experiment I get this error:

Error: Inner tuning and parameter transformations are currently not supported.

Copy link
Collaborator Author

@cxzhang4 cxzhang4 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My solution for now:

n_layers_values <- 1:10
latent_dim_values <- seq(10, 500, by = 10)
neurons_search_space <- mapply(
  neurons,
  expand.grid(n_layers = n_layers_values, latent_dim = latent_dim_values)$n_layers,
  expand.grid(n_layers = n_layers_values, latent_dim = latent_dim_values)$latent_dim,
  SIMPLIFY = FALSE
)

mlp = lrn("classif.mlp",
  activation = nn_relu,
  # neurons = to_tune(ps(
  #   n_layers = p_int(lower = 1, upper = 10), latent = p_int(10, 500),
  #   .extra_trafo = function(x, param_set) {
  #     list(neurons = rep(x$latent, x$n_layers))
  #   })
  # ),
  neurons = to_tune(neurons_search_space)

c(10, 10), c(10, 20), c(20, 10), c(20, 20)
)
),
batch_size = to_tune(16, 32, 64),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go bigger

Suggested change
batch_size = to_tune(16, 32, 64),
batch_size = to_tune(16, 32, 64, 128, 256),

tuner = tnr("grid_search"),
resampling = rsmp("cv"),
measure = msr("classif.acc"),
term_evals = 10
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely need more than 10

Suggested change
term_evals = 10
term_evals = 100

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run on GPU server (but without all cores)

# define an AutoTuner that wraps the classif.mlp
at = auto_tuner(
learner = mlp,
tuner = tnr("grid_search"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use MBO: more efficient

),
batch_size = to_tune(16, 32, 64),
p = to_tune(0.1, 0.9),
epochs = to_tune(upper = 1000L, internal = TRUE),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider reducing the max number of epochs


bmrdt = as.data.table(bmr)

fwrite(bmrdt, here("R", "rf_Use_case", "results", "bmrdt.csv"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
fwrite(bmrdt, here("R", "rf_Use_case", "results", "bmrdt.csv"))
fwrite(bmrdt, here("R", "rf_use_case", "results", "bmrdt.csv"))

Copy link
Collaborator Author

@cxzhang4 cxzhang4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run this with 10 evaluations on the GPU server (with not all of the cores) and report how long it takes.

Only parallelize the learners (one thread per learner) using future.

Run this experiment using the github installation (main branch) of mlr3torch. This will properly handle the interop threads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants