Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 927b3ef

Browse files
authored
Revised VisualizingAModel.md
- Minor updates
1 parent fcfa0de commit 927b3ef

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

tutorials/VisualizingAModel.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
Visualizing an ONNX Model
22
=========================
33

4-
To visualize an onnx model, we can use the [net drawer tool](https://github.com/onnx/onnx/blob/master/onnx/tools/net_drawer.py). This tool takes in a serialized ONNX model and produces a directed graph representation. The graph contains this information:
4+
To visualize an ONNX model, we can use the [net drawer tool](https://github.com/onnx/onnx/blob/master/onnx/tools/net_drawer.py). This tool takes in a serialized ONNX model and produces a directed graph representation. The graph contains the following information:
55

66
* Tensors
77
* Input/output tensors
88
* Intermediate tensors
9-
* Ops
9+
* Operators (ops)
1010
* Op type
1111
* Op number
1212
* Input tensor names
1313
* Output tensor names
14-
* Docstrings (Pytorch exports stack traces here, so this is a good way to get your bearings about the network topology)
14+
* Docstrings (PyTorch exports stack traces, so this is a good way to become familiarized with the network topology)
1515

1616
## SqueezeNet Example
1717

18-
Let's walk through an example visualizing a [SqueezeNet](https://arxiv.org/abs/1602.07360) model exported from [Pytorch](https://github.com/bwasti/AICamera/blob/master/Exporting%20Squeezenet%20to%20mobile.ipynb). An example visualization:
18+
Let's walk through an example visualizing a [SqueezeNet](https://arxiv.org/abs/1602.07360) model exported from [Pytorch](https://github.com/bwasti/AICamera/blob/master/Exporting%20Squeezenet%20to%20mobile.ipynb). Here's an example visualization:
1919

2020
![SqueezeNet Visualization](squeezenet.png)
2121

22-
#### Prerequisites
23-
* You will need [Graphviz](http://www.graphviz.org/), and particularly the `dot` command-line utility.
22+
**Prerequisites**
23+
* You will need [Graphviz](http://www.graphviz.org/) – specifically, the `dot` command-line utility.
2424
* You'll need the `pydot` Python package.
25-
* For the net drawer, you will need [ONNX](https://github.com/onnx/onnx), both installed and cloned somewhere (so you have access to the net_drawer.py file).
26-
* For the optional part (i.e. experimentation) you'll need Pytorch and Numpy
25+
* For the net drawer, you will need [ONNX](https://github.com/onnx/onnx), both installed and cloned somewhere (so that you have access to the `net_drawer.py` file).
26+
* For the optional part (i.e., experimentation), you'll need PyTorch and Numpy.
2727

28-
#### Convert an exported ONNX model to a Graphviz representation
28+
### Convert an exported ONNX model to a Graphviz representation
2929

30-
In the `assets` folder you should find a file named `squeezenet.onnx`. This is a serialized SqueezeNet model that was exported to ONNX from Pytorch. Go into your ONNX repository and run the following command:
30+
In the `assets` folder, you should find a file named `squeezenet.onnx`. This is a serialized SqueezeNet model that was exported to ONNX from PyTorch. Go into your ONNX repository and run the following:
3131

3232
python onnx/tools/net_drawer.py --input <path to squeezenet.onnx> --output squeezenet.dot --embed_docstring
33-
34-
The command line flags are as follows:
3533

36-
- `input` specifies the input filename, i.e. the serialized ONNX model you'd like to visualize
34+
The command line flags are described below:
35+
36+
- `input` specifies the input filename (i.e., the serialized ONNX model you would like to visualize).
3737
- `output` specifies where to write the Graphviz `.dot` file.
38-
- `embed_docstring` specifies that you'd like to embed the doc_string for each node in the graph visualization. This is implemented as a javascript alert() that is fired when you click on the node.
38+
- `embed_docstring` specifies that you'd like to embed the doc_string for each node in the graph visualization. This is implemented as a JavaScript alert() that occurs when you click on the node.
3939

4040
Now, we have a Graphviz file `squeezenet.dot`. We need to convert it into a viewable format. Let's convert this into an `svg` file like so:
4141

4242
dot -Tsvg squeezenet.dot -o squeezenet.svg
43-
44-
You should now have an `svg` file named `squeezenet.svg`. Now open this file in a web browser (I've tried Chrome and Firefox and they both work).
4543

46-
#### Interpreting the graph
44+
You should now have an `svg` file named `squeezenet.svg`. Open this file in a web browser.
45+
46+
### Interpreting the graph
4747

48-
Within the graph, white hexagons represent tensors and green rectangles represent ops. Within the op nodes, inputs are listed in order and outputs are listed in order. Note that the position of the Hexagons with respect to the ops does NOT represent input order. Finally, clicking on each op node will bring up an alert that contains the doc string (stack trace for Pytorch) that may have useful information about each node.
48+
Within the graph, white hexagons represent tensors and green rectangles represent ops. Within the op nodes, inputs and outputs are listed in order. Note that the position of the hexagons with respect to the ops does NOT represent input order. Clicking on each op node will bring up an alert that contains the doc string (stack trace for PyTorch), and may have useful information about each node.
4949

50-
#### (Optional) Exporting the ONNX model
50+
### (Optional) Exporting the ONNX model
5151

52-
This is the code that I used to create the exported model. You can put this into a Python script if you'd like to experiment:
52+
To create the exported model, you can put this into a Python script:
5353

5454
```python
5555
# Some standard imports

0 commit comments

Comments
 (0)