如何在H2ODeepLearningEstimator中提取隐藏层特征?

How to use extract the hidden layer features in H2ODeepLearningEstimator?

我发现H2O在R中有h2o.deepfeatures拉隐层特征的功能 https://www.rdocumentation.org/packages/h2o/versions/3.20.0.8/topics/h2o.deepfeatures

train_features <- h2o.deepfeatures(model_nn, train, layer=3)

但是我在Python中没有找到任何例子?谁能提供一些示例代码?

大多数 Python/R API 函数都是 REST 调用的包装器。参见 http://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/_modules/h2o/model/model_base.html#ModelBase.deepfeatures

因此,要将 R 示例转换为 Python 示例,请将模型移动为 this,所有其他参数应一起洗牌。 IE。手册中的示例变为(变量名中的点更改为下划线):

prostate_hex = ...
prostate_dl = ...
prostate_deepfeatures_layer1 = prostate_dl.deepfeatures(prostate_hex, 1)
prostate_deepfeatures_layer2 = prostate_dl.deepfeatures(prostate_hex, 2)

有时函数名称会略有变化(例如 h2o.importFile()h2o.import_file() 因此您需要在 http://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/index.html

处寻找它