手册说“逻辑。如果启用,自动标准化数据。如果禁用,用户必须提供适当缩放的输入数据。”
我尝试使用虹膜数据进行学习。
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
我的问题是如何将“结果垫”计算为“预测”?