1

我在训练带有 dropout 的 H2O 深度学习模型时出现下图

错位的预测

用于训练网络的代码是

  m.nn <- h2o.deeplearning(x = 1:(nc-1),                       
                       y = nc,                             
                       training_frame = datTra,  
                       #validation_frame = datTst,
                       nfolds = 5,  
                       activation = 'RectifierWithDropout', 
                       #input_dropout_ratio = 0.2, 
                       hidden_dropout_ratios = c(dro, dro, dro),          
                       hidden = c(120,30,8),
                       #hidden = 20,
                       epochs = 999,                          
                       #mini_batch_size = 100,
                       #variable_importances = TRUE,         
                       standardize = TRUE,
                       regression_stop = 1e-3,    
                       stopping_metric = "MSE",
                       stopping_tolerance = 1e-6,           
                       stopping_rounds = 10)

图对应dro=0.1

为什么我会有这种错位?有什么我错过的选择吗?

您可以在下面找到一段代码来尝试(从此处下载“SampleData.csv” )

library(h2o) 
library(readr)
library(ggplot2)

df <- as.data.frame(read_delim(file = 'SampleData.csv', delim = ";"))

localH2O <- h2o.init(ip = "localhost", startH2O = TRUE, nthreads = 2, max_mem_size = '4g')

dat_h2o <- as.h2o(x = df)

model.ref <- h2o.deeplearning(x = 1:(ncol(df)-1), y = ncol(df),                             
                         training_frame = dat_h2o, 
                         hidden = c(120,30,8), 
                         activation = 'Rectifier', 
                         epochs = 199, 
                         mini_batch_size = 10,
                         regression_stop = 0.1,
                         stopping_metric = "MSE",
                         stopping_tolerance = 1e-6,           
                         stopping_rounds = 10)

model.dro <- h2o.deeplearning(x = 1:(ncol(df)-1), y = ncol(df),                             
                         training_frame = dat_h2o,  
                         hidden = c(120,30,8),
                         activation = 'RectifierWithDropout', 
                         hidden_dropout_ratios = c(0.2, 0.2, 0.2),          
                         epochs = 199,
                         mini_batch_size = 10,                           
                         regression_stop = 0.1,
                         stopping_metric = "MSE",
                         stopping_tolerance = 1e-6,           
                         stopping_rounds = 10)

pred.ref <- as.data.frame(h2o.predict(object = model.ref, newdata = dat_h2o))
pred.dro <- as.data.frame(h2o.predict(object = model.dro, newdata = dat_h2o))

dfRes <- data.frame(cbind(df$SeqF, pred.ref$predict, pred.dro$predict))
colnames(dfRes) <- c('act', 'pred', 'pred2')

ggplot(data = dfRes) + geom_point(aes(x=act, y=pred), color='blue') + 
  geom_point(aes(x=act, y=pred2), color='red') + geom_abline() 
4

0 回答 0