2015-05-09 156 views
1

我想通過R包h2o, 使用H2O進行深度學習,並且想詢問H2O是否可以保存並重新加載訓練數據以便將來進行額外的訓練?H2O(來自R包h2o)是否可以保存並重新加載訓練數據?

我的代碼:

iris.train <- irisdata[-1,] 
iris.test <- irisdata[1,] 

res.dl <- h2o.deeplearning(x = 1:4, y = 5_offset, data = iris.train, activation = "Rectifier") 
pred.dl <- h2o.predict(object=res.dl, newdata=iris.test) 
res.err.dl[i] <- ifelse(as.character(as.matrix(pred.dl)[1,1]) == as.character(as.matrix(iris.test)[1,5]),0,1) 

回答

0
h2o.saveModel(object, dir = "", name = "", filename = "", force = FALSE) 

h2o.loadModel(path, conn = h2o.getConnection()) 
0

而在h2o.The模型建立深厚的學習模式,在2.8.6版本,我最近使用的工作示例保存在hdfs.For最新版本,你可能不得不刪除分類= T開關,並且必須用training_frame替換數據。

library(h2o) 
h = h2o.init(ip="xx.xxx.xxx.xxx", port=54321, startH2O = F) 

cTrain.h2o <- as.h2o(h,cTrain,key="c1") 
cTest.h2o <- as.h2o(h,cTest,key="c2") 

nh2oD<-h2o.deeplearning(x =c(1:12),y="tgt",data=cTrain.h2o,classification=F,activation="Tanh", 
         rate=0.001,rho=0.99,momentum_start=0.5,momentum_stable=0.99,input_dropout_ratio=0.2,       
         hidden=c(12,25,11,11),hidden_dropout_ratios=c(0.4,0.4,0.4,0.4), 
         epochs=150,variable_importances=T,seed=1234,reproducible = T,l1=1e-5, 
         key="dn") 

hdfsdir<-"hdfs://xxxxxxxxxx/user/xxxxxx/xxxxx/models" 

h2o.saveModel(nh2oD,hdfsdir,name="DLModel1",save_cv=T,force=T) 

test=h2o.loadModel(h,path=paste0(hdfsdir,"/","DLModel1"))