簡體   English   中英

bnlearn的並行化(並行包)

[英]parallelization of bnlearn (with parallel package)

我使用Rbnlearn來估計貝葉斯網絡結構。 它具有使用parallel包的內置parallel 但是,這不起作用。

使用聯機幫助頁bnlearn::parallel integration的示例:

library(parallel)
library(bnlearn)

cl = makeCluster(2)

# check it works.
clusterEvalQ(cl, runif(10))    # -> this works

data(learning.test)
res = gs(learning.test, cluster = cl)

在這里我得到錯誤"Error in check.cluster(cluster) : cluster is not a valid cluster object."

有人知道怎么做這個嗎?

這是一個錯誤。 請將其報告給軟件包維護者。

這是check.cluster的代碼:

function (cluster) 
{
    if (is.null(cluster)) 
        return(TRUE)
    if (any(class(cluster) %!in% supported.clusters)) 
        stop("cluster is not a valid cluster object.")
    if (!requireNamespace("parallel")) 
        stop("this function requires the parallel package.")
    if (!isClusterRunning(cluster)) 
        stop("the cluster is stopped.")
}

現在,如果你看一下cl的類:

class(cl)
#[1] "SOCKcluster" "cluster" 

讓我們重現一下檢查:

bnlearn:::supported.clusters
#[1] "MPIcluster"  "PVMcluster"  "SOCKcluster"

`%!in%` <- function (x, table) {
  match(x, table, nomatch = 0L) == 0L
}
any(class(cl) %!in% bnlearn:::supported.clusters)
#[1] TRUE

cluster不在supported.clusters 我相信,該函數應該只檢查集群是否有受支持的類,而不是它是否具有不受支持的類。

作為解決方案,您可以更改supported.clusters

assignInNamespace("supported.clusters", 
                  c("cluster", "MPIcluster",  
                    "PVMcluster", "SOCKcluster"), 
                  "bnlearn")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM