Reputation: 46423
When creating a neural network with Keras:
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
...
the function model.summary
helps to get the big picture of the structure.
To get a better idea of the structure, is there a function in Keras or Tensorflow (or another library) to automatically generate a 3D diagram of the structure? like this:
or
or
Generating such a diagram file would be totally possible from the model
object.
TL;DR:
INPUT: a Keras model
variable
OUTPUT: a PNG image
PS:
I already know this online tool: http://alexlenail.me/NN-SVG/LeNet.html and this question How to draw Deep learning network architecture diagrams? but here the idea would be to generate this automatically from Keras.
Linked but not identical: How do you visualize neural network architectures? .
Different to How can a neural network architecture be visualized with Keras?
Linked project: https://github.com/stared/keras-sequential-ascii
Linked article: Simple diagrams of convoluted neural networks
Doing from keras.utils import plot_model
plot_model(model, to_file='model.png', show_shapes=True, show_layer_names=True)
already gives something but it's not 3D:
Note: add this for Windows: os.environ["PATH"] += os.pathsep + r'C:\Program Files (x86)\Graphviz2.38\bin'
after installing Graphviz
if you want to use plot_model
.
Upvotes: 11
Views: 6128
Reputation: 85
Are you talking about this: https://keras.io/visualization/
from keras.utils import plot_model
plot_model(model, to_file='model.png')
This saves the structure of your model with input and output tensors as png. But unfortunately only the scheme, not three-dimensional
Upvotes: 4