Visualize Neural Network Model using Netron

Visualize Neural Network Model using Netron

Netron is an open-source tool which allows visualizing neural network, deep learning and machine learning models. Netron allows analyzing model structure and ensure it matches your expected design. It supports a variety of frameworks and model formats.

Netron is a cross-platform tool which can be installed as a Desktop application. It can be downloaded from the releases page of the lutzroeder/netron repository. Choose the installer depending on your operating system (.exe for Windows, .dmg for macOS, .AppImage for Linux).

Also, Netron can visualize models in the browser. In this tutorial, we will show how you can install Netron as a Python server. We will create a model with Keras and TensorFlow 2.

Using pip package manager, install tensorflow and netron from the command line.

pip install tensorflow
pip install netron

We created a simple model which consists of a sequence of one Flatten layer and two Dense layers. We saved model in HDF5 format (.h5 extension). A server started by using netron.start() function.

from tensorflow import keras
import netron

model = keras.Sequential([
    keras.layers.Flatten(input_shape=(28, 28)),
    keras.layers.Dense(128, activation='relu'),
    keras.layers.Dense(10, activation='softmax')
])

model.save('model.h5')

netron.start('model.h5')

Then it will open the browser with visualized model. By default, a model is served at http://localhost:8080.

Netron Browser Version

It's also possible to generate SVG or PNG images of the models.

Export Model as SVG or PNG Image

Leave a Comment

Cancel reply

Your email address will not be published.