【问题标题】:Keras Model Architecture [duplicate]Keras 模型架构 [重复]
【发布时间】:2019-02-10 19:03:46
【问题描述】:

我创建了 Keras 模型。然后我使用了一个函数来为您绘制模型架构图。它创建了如下所示的 png 文件。

创建模型的代码:

model = Sequential()
model.add(LSTM(50, input_shape=(train_X.shape[1], train_X.shape[2])))
model.add(Dense(1, activation='linear'))
model.compile(loss='mae', optimizer='adam', metrics=[self.coeff_determination])

创建架构的png图像的行:

plot_model(model, to_file='C:\CSV\model.png', show_layer_names=True, show_shapes=True)

这是我得到的图像:

问题是图表顶部的大数字的含义。

【问题讨论】:

  • 问题已编辑
  • 干得好 - 删除了反对票 ;)
  • 谢谢@mirdad,您的评论帮助了我。我想我解决了这个问题。显然问题出在sequential.py中。现在我得到这张图片:link

标签: python machine-learning keras deep-learning


【解决方案1】:

最初回答here。检查此链接:https://github.com/keras-team/keras/issues/10638

在 keras/engine/sequential.py - 注释掉以下代码:

@property
def layers(self):
    # Historically, `sequential.layers` only returns layers that were added
    # via `add`, and omits the auto-generated `InputLayer`
    # that comes at the bottom of the stack.
    if self._layers and isinstance(self._layers[0], InputLayer):
        return self._layers[1:]
    return self._layers

【讨论】:

  • 由于该问题的答案存在于该重复问题中,因此您最好不要发布答案,而是将该问题标记为重复关闭。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-05
  • 2019-11-24
  • 1970-01-01
相关资源
最近更新 更多