手册说"逻辑。如果启用,则自动标准化数据。如果禁用,用户必须提供正确缩放的输入数据。"
我尝试使用虹膜数据学习。
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
我的问题是如何计算结果? as&#39;预测&#39; ??
答案 0 :(得分:0)
standardize()
与R的scale()
相同。在统计建模中,您不希望将一个变量的效果与其他变量相比非常重,仅仅因为它们的比例。例如,在一个模型中考虑年龄和薪水。你希望人类年龄在0-100之间,而工资可以达到20000美元 - 大CEO的工资。因此,在模型的数字修正中,20000美元将非常大,因此与年龄20相比非常占主导地位。为了使两者达到同一水平并使这些变量同样有效,建议使用standardize()
。