【发布时间】:2021-01-11 21:34:57
【问题描述】:
我希望能够检查我的神经网络上的节点结构。具体来说,我使用 L1 和 L2 正则化,想知道我的权重有多少比例萎缩到零。我训练有素的神经网络是否使用每个节点,或者我可以使用更少的隐藏节点吗?那种东西。
这是一个玩具问题:
library(h2o)
h2o.init()
x <-seq(-10,10,by=0.0002)
y <- dnorm(x,sd=2)*sin(2*x) # The function the neuralnet will attempt to fit
plot(x,y,type="l")
df <- data.frame(x=x,y=y)
df2 <- as.h2o(df)
model <- h2o.deeplearning(df2,
x=1,
y=2,
hidden=c(200,100,50,10,5), # way more hidden nodes than it needs
l1=0.0000001, # regularisation to reduce the number of unnecessary nodes
l2=0.0000001,
activation="Tanh",
export_weights_and_biases=TRUE)
P <- as.data.frame(h2o.predict(model,df2))
lines(x,P$predict,col=2)
legend("topleft",legend=c("Training data","nn output"),col=c(1,2),lwd=1)
h2o 中是否有一个函数可以为我提供所有权重的信息?
(我试过 h2o.weights(),它似乎只给了我第一层)
如果模型是 S4 对象,那么检查 S4 对象的方法是什么?
额外问题:在 h2o 中是否有任何可视化节点结构的能力?
【问题讨论】:
标签: r deep-learning h2o