小编Hag*_*Tz.的帖子

绘图模型不显示模型层,仅显示模型名称

我正在尝试使用 TensorFlow2 构建一些模型,因此我创建了一个模型类,如下所示:

import tensorflow as tf

class Dummy(tf.keras.Model):
    def __init__(self, name="dummy"):
        super(Dummy, self).__init__()
        self._name = name

        self.dense1 = tf.keras.layers.Dense(4, activation=tf.nn.relu)
        self.dense2 = tf.keras.layers.Dense(5, activation=tf.nn.softmax)

    def call(self, inputs, training=False):
        x = self.dense1(inputs)
        return self.dense2(x)

model = Dummy()
model.build(input_shape=(None,5))
Run Code Online (Sandbox Code Playgroud)

现在我想绘制模型,同时使用summary()返回我期望的内容,plot_model(model, show_shapes=True, expand_nested=True)仅返回带有模型名称的块。

如何返回模型的图表?

python python-3.x keras tensorflow tensorflow2.x

2
推荐指数
1
解决办法
1938
查看次数

标签 统计

keras ×1

python ×1

python-3.x ×1

tensorflow ×1

tensorflow2.x ×1