本文介绍了多核中的R caret nnet软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以通过利用foreach软件包,nnet和插入符号软件包来使用多核并行地训练神经网络模型吗?

Can we train a neural network model in parallel using multicores by leveraging foreach package, nnet and caret packages ?

我仅看到并行执行randomforest.神经网络是否可能.

I only see randomforest implementation in parallel. Is neural network possible.

我对插入符号的训练功能特别感兴趣,该功能可以对最佳隐藏层和衰减大小进行网格搜索.在单个内核上运行需要很长时间.

I am especially interested in the caret's train function which can do a grid search for optimal hidden layers and decay size. This take a long time to run on a single core.

感谢您的帮助.

推荐答案

是要实现算法还是要并行进行重采样?如果以后要查找,则只需通过registerDoMC()注册要使用的内核数,它将并行运行这些内核.例如:

Are looking to implement the algorithm or your resampling in parallel? If you're looking for the later all you have to do simply register the number of cores you would like to use via registerDoMC() and it will run those in parallel. Ex:

> library(caret)
> library(doMC)
>
> registerDoMC(4)
> tc <- trainControl(method="boot",number=25)
> train(Species~.,data=iris,method="nnet",trControl=tc)
# weights:  43
initial  value 596.751921
iter  10 value 61.068365
iter  20 value 16.320051
iter  30 value 9.581306
iter  40 value 8.639828
iter  50 value 8.492001
iter  60 value 8.364661
iter  70 value 8.264618
iter  80 value 8.082598
iter  90 value 5.911050
iter 100 value 1.179339
final  value 1.179339
stopped after 100 iterations
450 samples
  4 predictors
  3 classes: 'setosa', 'versicolor', 'virginica'

No pre-processing
Resampling: Bootstrap (25 reps)

Summary of sample sizes: 450, 450, 450, 450, 450, 450, ...

Resampling results across tuning parameters:

  size  decay  Accuracy  Kappa  Accuracy SD  Kappa SD
  1     0      0.755     0.64   0.251        0.366
  1     1e-04  0.834     0.758  0.275        0.401
  1     0.1    0.964     0.946  0.0142       0.0214
  3     0      0.961     0.941  0.0902       0.135
  3     1e-04  0.972     0.958  0.0714       0.104
  3     0.1    0.977     0.966  0.0108       0.0163
  5     0      0.973     0.96   0.0579       0.0888
  5     1e-04  0.987     0.98   0.00856      0.0129
  5     0.1    0.978     0.966  0.0112       0.0168

Accuracy was used to select the optimal model using  the largest value.
The final values used for the model were size = 5 and decay = 1e-04.

正在运行的4个核心的屏幕截图:

Screenshot of 4 cores running:

这篇关于多核中的R caret nnet软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 00:35