Keras plot_model没有正确显示输入层 [英] Keras plot_model not showing the input layer appropriately

查看:164
本文介绍了Keras plot_model没有正确显示输入层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的模型是这样定义的:

My model is defined as such:

model = keras.models.Sequential()
model.add(layers.Embedding(max_features, 128, input_length=max_len,
                       input_shape=(max_len,), name='embed'))
model.add(layers.Conv1D(32, 7, activation='relu'))
model.add(layers.MaxPooling1D(5))
model.add(layers.Conv1D(32, 7, activation='relu'))
model.add(layers.GlobalMaxPooling1D())
model.add(layers.Dense(1))

,当我使用plot_model函数将其绘制出来时:

and when I use the plot_model function to draw it out:

from keras.utils import plot_model

plot_model(model, show_shapes=True, to_file='model.png')

我得到的图形是

其中输入层是一系列数字.有人知道如何让它正确显示输入吗?

Where the input layer is a series of numbers. Does anybody know how it let it show the input properly?

推荐答案

在升级Keras之后发生在我身上

It happened to me after upgrading Keras

检查此链接: https://github.com/keras-team/keras/问题/10638

在keras/engine/sequential.py

In 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

这篇关于Keras plot_model没有正确显示输入层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆