微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从本地 Windows 机器在 VPS 上安装神经网络 R 包?

如何解决如何从本地 Windows 机器在 VPS 上安装神经网络 R 包?

我正在尝试在 R 中并行训练多个 ANN。问题是我不知道如何从本地机器在 VPS 上安装 Neuralnet。 我正在寻找一些类似以下的说明,它非常适合在 VPS 上安装 R 和 Future 包:

library(parallel)
cl <- parallelly::makeClusterPSOCK("VPS ip",user = "my_user")
clusterEvalQ(cl[1],{ dir.create(Sys.getenv("R_LIBS_USER"),recursive=TRUE) })
clusterEvalQ(cl[1],{ install.packages("future",repos = "https://cloud.r-project.org") })
stopCluster(cl)

我正在测试的在 R 中实现并行编码的脚本如下:


library(parallelly)
library(future)
library(parallel)
library(neuralnet)

data(iris)
head(iris)
nrow(iris)

red <- function(x) {
  fold.test <- sample(nrow(iris),nrow(iris) / 3)
  test <- iris[fold.test,]
  train <- iris[-fold.test,]
  ann <- neuralnet(as.numeric(Species) ~ Sepal.Length + Sepal.Width +
                     Petal.Length + Petal.Width,train,hidden = c(10,5))
  ann
  output <- compute(ann,test[,c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width")])

  result <- data.frame(
    Real = test$Species,Predicted = levels(iris$Species)[round(output$net.result)])
  result

  table(result$Predicted,result$Real)
  mse <-table(result$Predicted,result$Real)
  
  x
  
}

local_workers <- rep("localhost",times=3)
workers <- rep("VPS ip",times =1)
workers <- c(workers,local_workers)

system.time({
  cl <- parallelly::makeClusterPSOCK(workers,user = "my_user")
  parallel::clusterExport(cl,"iris")
  resultados <- parSapply(cl,1:20,red)})
  #resultados
stopCluster(cl)

而运行时出现的错误是:

Error in checkForRemoteErrors(val) : 
  4 nodes produced errors; first error: Could not find function "neuralnet"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。