相关疑难解决方法(0)

如何绘制 Keras/Tensorflow 子类化 API 模型?

我使用 Keras Subclassing API 创建了一个可以正确运行的模型。也model.summary()可以正常工作。当尝试使用tf.keras.utils.plot_model()可视化模型的架构时,它只会输出以下图像:

在此输入图像描述

这几乎感觉像是 Keras 开发团队的一个笑话。这是完整的架构:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
from sklearn.datasets import load_diabetes
import tensorflow as tf
tf.keras.backend.set_floatx('float64')
from tensorflow.keras.layers import Dense, GaussianDropout, GRU, Concatenate, Reshape
from tensorflow.keras.models import Model

X, y = load_diabetes(return_X_y=True)

data = tf.data.Dataset.from_tensor_slices((X, y)).\
    shuffle(len(X)).\
    map(lambda x, y: (tf.divide(x, tf.reduce_max(x)), y))

training = data.take(400).batch(8)
testing = data.skip(400).map(lambda x, y: (tf.expand_dims(x, 0), y))

class NeuralNetwork(Model):
    def __init__(self):
        super(NeuralNetwork, self).__init__()
        self.dense1 = Dense(16, input_shape=(10,), activation='relu', name='Dense1')
        self.dense2 = Dense(32, activation='relu', …
Run Code Online (Sandbox Code Playgroud)

python plot deep-learning keras tensorflow

9
推荐指数
1
解决办法
2308
查看次数

标签 统计

deep-learning ×1

keras ×1

plot ×1

python ×1

tensorflow ×1