making a picture of a neural network in tensorflow
-
17-12-2020 - |
質問
I'm new to Machine Learning and I have just gone through a tutorial explaining how to create a neural network in TensorFlow. I was wondering if it is possible to visualize the neural network I created. The output should be a picture like this
Thanks.
MRE:
import tensorflow as tf
ann = tf.keras.models.Sequential()
ann.add(tf.keras.layers.Dense(units=6, activation='relu'))
ann.add(tf.keras.layers.Dense(units=6, activation='relu'))
ann.add(tf.keras.layers.Dense(units=1, activation='sigmoid'))
tf.keras.utils.plot_model(ann, to_file='model.png', show_shapes=True,
show_layer_names=True, rankdir='TB',
expand_nested=False, dpi=96
)
解決
This should do the trick:
tf.keras.utils.plot_model(
model, to_file='model.png', show_shapes=False, show_layer_names=True,
rankdir='TB', expand_nested=False, dpi=96
)
This will generate an image like:
所属していません datascience.stackexchange