2017-08-16 38 views
0

我使用h2o.deeplearning函數來實現R中的DNN。怎麼做h2o.deeplearning初始化的重量?

我想初始化深度神經網絡的迭代和性能改進的權重。

我知道,稱重初始化應該是-1和+1之間的較小值,而不是一個較大的值。

那麼,什麼是參數代碼中h2o.deeplearning該initialze重量????以及如何使用它來初始化-1和+1之間?

請幫助我..!

回答

0

如果我們檢查的?h2o.deeplearning

文檔initial_weights H2OFrame ID的列表來初始化重本模型的 矩陣。

下面是設定的權重

library(h2o) 
h2o.init() 
iris.hex <- as.h2o(iris) 
iris.dl <- h2o.deeplearning(x = 1:4, y = 5, training_frame = iris.hex, 
    hidden=c(10,10),export_weights_and_biases = TRUE 
) 
w1 <- h2o.weights(iris.dl,1) 
w2 <- h2o.weights(iris.dl,2) 
w3 <- h2o.weights(iris.dl,3) 
b1 <- h2o.biases(iris.dl,1) 
b2 <- h2o.biases(iris.dl,2) 
b3 <- h2o.biases(iris.dl,3) 

dl <- h2o.deeplearning(1:4,5,iris.hex,hidden=c(10,10),initial_weights=c(w1,w2,w3), 
    initial_biases=c(b1,b2,b3)) 

p1 <- h2o.predict(dl, iris.hex) 
p1 
# predict setosa versicolor virginica 
#1 setosa 0.9967546 0.0032424531 2.946375e-06 
#2 setosa 0.9943469 0.0056346023 1.845851e-05 
#3 setosa 0.9990881 0.0009072309 4.663780e-06 
#4 setosa 0.9990550 0.0009393998 5.593951e-06 
#5 setosa 0.9985592 0.0014391955 1.568052e-06 
#6 setosa 0.9966511 0.0033477623 1.121636e-06 

#[150 rows x 4 columns] 

關於歸一化的例子,它將被h2o來完成。同時檢查here