如何在R中使用GPU进行catboost网格搜索?

我正在使用R中的catboost软件包设置网格搜索。在catboost文档(https://catboost.ai/docs/)之后,可以使用R中的3个独立命令进行超参数调整的网格搜索,

fit_control <- trainControl(method = "cv",number = 4,classprobs = TRUE)
grid <- expand.grid(depth = c(7,8,9,10),learning_rate = c(0.1,0.2,0.3,0.4),iterations = c(10,100,1000))
report <- train(df.scale,as.factor(make.names(as.matrix(tier1))),method = catboost.caret,logging_level = 'Verbose',preProc = NULL,tuneGrid = grid,trControl = fit_control)

在深度,学习率和迭代次数的不同值之间进行搜索。这些命令看起来足够好,只是我不知道在哪里输入task_type =“ GPU”的选项。希望对使用R来指定使用GPU查找最佳参数的方法有所帮助。

mingshiyy483 回答:如何在R中使用GPU进行catboost网格搜索?

您似乎正在使用脱字符号包来执行训练。在这种情况下,插入符号包似乎没有将任何其他参数传递给catboost.train函数,因此它可能不支持GPU功能。从the code的插入符中可以看出,...参数没有传递给catboost.train函数。

#' Fit model based on input data
#'
#' @param x,y: the current data used to fit the model
#' @param wts: optional instance weights (not applicable for this particular model)
#' @param param: the current tuning parameter values
#' @param lev: the class levels of the outcome (or NULL in regression)
#' @param last: a logical for whether the current fit is the final fit
#' @param weights: weights
#' @param classProbs: a logical for whether class probabilities should be computed
#'
#' @noRd
catboost.caret$fit <- function(x,y,wts,param,lev,last,weights,classProbs,...) {
    param <- c(param,list(...))
    if (is.null(param$loss_function)) {
        param$loss_function <- "RMSE"
        if (is.factor(y)) {
            param$loss_function <- "Logloss"
            if (length(lev) > 2) {
                param$loss_function <- "MultiClass"
            }
            y <- as.double(y) - 1
        }
    }
    test_pool <- NULL
    if (!is.null(param$test_pool)) {
        test_pool <- param$test_pool
        if (class(test_pool) != "catboost.Pool")
            stop("Expected catboost.Pool,got: ",class(test_pool))
        param <- within(param,rm(test_pool))
    }
    pool <- catboost.from_data_frame(x,weight = wts)
    model <- catboost.train(pool,test_pool,param)
    model$lev <- lev
    return(model)
}

根据您对R和插入符号的熟练程度,您可以add your own model to caret,方法是基本上将模型复制到插入符号github位置,然后对其进行修改以接受GPU参数,该参数应按{{3 }}

本文链接:https://www.f2er.com/2546595.html

大家都在问