双约化环的Julia并行
我想在Julia的并行for循环中执行两个约化。我试图在构建每棵树时,计算并行for循环中随机林中的错误。有什么想法吗 当前:双约化环的Julia并行,julia,Julia,我想在Julia的并行for循环中执行两个约化。我试图在构建每棵树时,计算并行for循环中随机林中的错误。有什么想法吗 当前: forest = @parallel (vcat) for i in 1:ntrees inds = rand(1:Nlabels, Nsamples) build_tree(labels[inds], features[inds,:], nsubfeatures) end 直观地说,我想要的是在这个for循环中做一个加法,以得到包外错误。这就是我希望
forest = @parallel (vcat) for i in 1:ntrees
inds = rand(1:Nlabels, Nsamples)
build_tree(labels[inds], features[inds,:], nsubfeatures)
end
直观地说,我想要的是在这个for循环中做一个加法,以得到包外错误。这就是我希望它能够发挥作用的方式:
forest, ooberror = @parallel (vcat, +) for i in 1:ntrees
inds = rand(1:Nlabels, Nsamples)
tree = build_tree(labels[inds], features[inds,:], nsubfeatures)
error = geterror(ids, features, tree)
(tree, error)
end
就简单性和清晰性而言,使用类型可能是最好的,例如
type Forest
trees :: Vector
error
end
join(a::Forest, b::Forest) = Forest(vcat(a.trees,b.trees), a.error+b.error)
#...
forest = @parallel (join) for i in 1:ntrees
inds = rand(1:Nlabels, Nsamples)
tree = build_tree(labels[inds], features[inds,:], nsubfeatures)
error = geterror(ids, features, tree)
Forest(tree, error)
end