Model Visualizer

This describes how to view an ML model in an interactive webpage using the MLTK’s commands/APIs.

Note

Any .tflite or .h5 model file will work with the model visualizer.
i.e. The model file does not need to be generated by the MLTK to view the model.

Quick Reference

Overview

Model visualization allows for viewing how the various layers of a model are connected. Model visualization is enabled using the Netron machine learning model viewer, a tool for viewing models in an interactive webpage.

Note

  • Model visualization is done entirely in the local web-browser. The model is not uploaded to any remote servers

  • Models may also be viewed by dragging and dropping a .tflite or .h5 model file on the http://netron.app webpage

Command

Model visualization from the command-line is done using the view operation.

For more details on the available command-line options, issue the command:

mltk view --help

Example 1: View Keras model

In this example, we view the trained .h5 model file in the image_classification model’s archive.

NOTE: The model graph will appear in your web-browser.

mltk view image_classification

Example 2: View Tensorflow-Lite model

In this example, we view the trained .tflite model file in the image_classification model’s archive.

NOTE: The model graph will appear in your web-browser.

mltk view image_classification --tflite

Example 3: View external Tensorflow-Lite model

The given model need not be generated by the MLTK. External models are also supported by the view command.

NOTE: The model graph will appear in your web-browser.

mltk view ~/workspace/my_model.tflite

Example 4: View model before training

Training a model can be very time-consuming, and it is useful to view a model before investing time and energy into training it. For this reason, the MLTK view command features a --build flag to build a model and view it before the model is fully trained.

In this example, the image_classification model is built at command-execution-time and this file is opened in the viewer. Note that only the model specification script is required, it does not need to be trained first.

NOTE: The model graph will appear in your web-browser.

mltk view image_classification --tflite --build

Python API

Model visualization is accessible via the view_model API

Examples using this API may be found in view_model.ipynb