keras如何定义输入层(基本理解)层数

发布于 2025-02-05 18:51:12 字数 449 浏览 2 评论 0原文

我尝试遵循教程。

模型的构建以

netw <- keras_model_sequential()

### one input layer, one output layer and one hidden layer
netw %>% layer_dense(units = 500, activation = "relu", input_shape = c(6)) %>%
  layer_dense(units=300, activation="relu") %>%
  layer_dense(units=2, activation="softmax")

单元的形式开始定义节点的数量。我对层数感到困惑。由于有6个功能,因此输入层应具有6个节点。为什么它的单位= 500?这是否真的指定了一个带有6个节点的输入层和一个带有500个节点的第二层?因此,评论中会有4层而不是三层?

I try to follow a tutorial.

The building of the model starts with

netw <- keras_model_sequential()

### one input layer, one output layer and one hidden layer
netw %>% layer_dense(units = 500, activation = "relu", input_shape = c(6)) %>%
  layer_dense(units=300, activation="relu") %>%
  layer_dense(units=2, activation="softmax")

units define the number of nodes. I am confused about the number of layers. The input layer should have 6 nodes, since there are 6 features. Why does it have units=500? Does this really specify an input layer with 6 nodes and a second layer with 500 nodes? So there would be 4 layers instead of the three stated in the comment?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北方。的韩爷 2025-02-12 18:51:12

输入形状确实是指输入层的大小。这是被馈入网络的数据点的数量,而单位= 500是传递数据的网络节点数量。

这是您模型的可视化:

”模型可视化“

如您所见,模型中确实有四层。通常不计算输入层,因为每个网络通常都包含一个输入层。更具体地说,输入层不是计算层,因此只进行了三个级别的计算层。

The input shape does refer to the size of the input layer. This is the number of data point being fed into the network while units = 500 is the number of network nodes the data is being passed to.

Here is a visualization of your model:

Model visualisation

As you can see, there are indeed four layers in the model. The input layer is not generally counted because every network will generally contain an input layer. More specifically, the input layer is not a computation layer, so there are only three levels of computation being carried out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文