0

手册说“逻辑。如果启用,自动标准化数据。如果禁用,用户必须提供适当缩放的输入数据。”

我尝试使用虹膜数据进行学习。

R源代码

library(h2o)
h2o.init()

xx <- data.frame(c(1:10), c(1:10) * 10, c(1:10) * 100)

iris.hex <- as.h2o(xx)
bb <- h2o.deeplearning(x = 1:2, y = 3, training_frame = iris.hex, standardize = TRUE, 
                   activation = "Rectifier", hidden = c(10, 10), export_weights_and_biases = TRUE)

predictions <- as.data.frame(h2o.predict(bb, iris.hex))

weights_01 <- as.matrix(h2o.weights(bb, matrix_id = 1))
weights_02 <- as.matrix(h2o.weights(bb, matrix_id = 2))
weights_03 <- as.matrix(h2o.weights(bb, matrix_id = 3))

biases_01 <- as.matrix(h2o.biases(bb, vector_id = 1))
biases_02 <- as.matrix(h2o.biases(bb, vector_id = 2))
biases_03 <- as.matrix(h2o.biases(bb, vector_id = 3))

xx_temp <- xx ## This step standardizes my data
for (i in 1:3){
  xx_temp[ , i] <- xx_temp[ , i] / max(xx_temp[ , i])
}

result_mat <- matrix(nrow = 10, ncol = 1)
for (j in 1:10){
  asdf <- as.matrix(xx_temp[j, 1:2])
  asdf <- weights_01 %*% t(asdf) + biases_01
  asdf[asdf < 0] <- 0

  asdf <- weights_02 %*% (asdf) + biases_02
  asdf[asdf < 0] <- 0

  asdf <- weights_03 %*% (asdf) + biases_03
  result_mat[j, 1] <- asdf
}
result_mat

cbind(predictions[1:10, 1], result_mat) ## << What is differences of two data 

我的问题是如何将“结果垫”计算为“预测”?

4

1 回答 1

0

standardize()与 R相同scale()。在统计建模中,您不希望一个变量的影响与另一个变量相比非常重,因为它们的规模。例如,在一个模型中考虑年龄和薪水。你期望的人类年龄在 0-100 之间,而薪水可以达到 20000 美元—— CEO 的薪水。因此,在模型中的数值修正中,与 20 岁相比,20000 美元将非常大,因此非常占主导地位。为了使两者达到相同水平并使这些变量同样有效,建议使用standardize().

于 2016-06-27T14:30:58.207 回答