【问题标题】:how to do initialize the weight in h2o.deeplearning?如何在 h2o.deeplearning 中初始化权重?
【发布时间】:2023-04-03 01:08:01
【问题描述】:

我使用h2o.deeplearning 函数在 R 中执行 DNN。

我想为深度神经网络的迭代和性能改进初始化权重。

我知道称重初始化应该是-1和+1之间的小值,而不是大值。

那么,h2o.deeplearning中初始化权重的参数代码是什么???以及如何使用它在-1和+1之间进行初始化??

请帮帮我..!

【问题讨论】:

    标签: r neural-network deep-learning h2o


    【解决方案1】:

    如果我们查看?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

    【讨论】:

      猜你喜欢
      • 2018-09-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-21
      • 2019-04-14
      • 2021-05-08
      • 2017-09-15
      • 2018-11-09
      • 1970-01-01
      相关资源
      最近更新 更多