Last active
January 31, 2017 08:16
-
-
Save HackerEarthBlog/94ffe14fa6bd6175c3fec6d9717378a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set parameter space | |
activation_opt <- c("Rectifier","RectifierWithDropout", "Maxout","MaxoutWithDropout") | |
hidden_opt <- list(c(10,10),c(20,15),c(50,50,50)) | |
l1_opt <- c(0,1e-3,1e-5) | |
l2_opt <- c(0,1e-3,1e-5) | |
hyper_params <- list( activation=activation_opt, | |
hidden=hidden_opt, | |
l1=l1_opt, | |
l2=l2_opt ) | |
#set search criteria | |
search_criteria <- list(strategy = "RandomDiscrete", max_models=10) | |
#train model | |
dl_grid <- h2o.grid("deeplearning" | |
,grid_id = "deep_learn" | |
,hyper_params = hyper_params | |
,search_criteria = search_criteria | |
,training_frame = trainh2o | |
,x=x | |
,y=y | |
,nfolds = 5 | |
,epochs = 100) | |
#get best model | |
d_grid <- h2o.getGrid("deep_learn",sort_by = "accuracy") | |
best_dl_model <- h2o.getModel(d_grid@model_ids[[1]]) | |
h2o.performance (best_dl_model,xval = T) #CV Accuracy - 84.7% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment