R H2O - 详细摘要

时间:2016-09-26 17:43:12

标签: r model h2o

我使用h2o库进行分类。我想知道它所制造的每个节点的重量细节。假设我使用model命名模型,如果我使用summary(model),它将仅显示每个图层的平均权重和平均偏差,我需要知道每个权重的详细信息。是否可以打印每个细节重量? 任何建议,将不胜感激。 抱歉可怕的英文

train[1,] 
0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  0,  1,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  0,  1,  0,  0,  0,  0,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  0,  0,  1,  1,  0,  0,  0,  0,  0,  1,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1

train[2,] 
1,  1,  1,  1,  0,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  1,  1,  0,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  0,  0,  0,  0,  0,  0,  0,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  2

model = h2o.deeplearning(x = 1:100,y = 101
                         training_frame = train,
                         activation = "Tanh",
                         balance_classes = TRUE, 
                         hidden = c(15,15),
                         momentum_stable = 0.99,
                         epochs = 50)

Scoring History: 
            timestamp   duration training_speed   epochs iterations     samples training_rmse training_logloss
1 2016-09-26 23:50:53  0.000 sec                 0.00000          0    0.000000                               
2 2016-09-26 23:50:53  0.494 sec  8783 rows/sec  5.00000          1  650.000000       0.81033          2.04045
3 2016-09-26 23:50:53  1.053 sec 10586 rows/sec 50.00000         10 6500.000000       0.23170          0.22766
  training_classification_error
1                              
2                       0.63077
3                       0.00000

这是我的模型摘要的一部分

 layer units    type dropout       l1       l2 mean_rate rate_rms momentum mean_weight weight_rms mean_bias bias_rms
1     1   100   Input  0.00 %                                                                                        
2     2    15    Tanh  0.00 % 0.000000 0.000000  0.005683 0.001610 0.000000    0.004570   0.148204 -0.019728 0.061853
3     3    15    Tanh  0.00 % 0.000000 0.000000  0.003509 0.000724 0.000000    0.003555   0.343449  0.007262 0.110244
4     4    26 Softmax         0.000000 0.000000  0.010830 0.006383 0.000000    0.005078   0.907516 -0.186089 0.166363

1 个答案:

答案 0 :(得分:2)

构建模型时,设置标志以导出权重和偏差。然后,在构建模型后,您可以使用h2o.weights()h2o.biases()

model = h2o.deeplearning(x = 1:100,y = 101
                     training_frame = train,
                     activation = "Tanh",
                     balance_classes = TRUE, 
                     hidden = c(15,15),
                     momentum_stable = 0.99,
                     epochs = 50,
                     export_weights_and_biases = TRUE # <--- add this
                     )
firstLayerWeights = h2o.weights(model, 1)
secondLayerWeights = h2o.weights(model, 2)