6

How to get dimensions of output layers in onnx neural net?

I can get onnx graph, but there is no output dimensions:

~/onnx-tensorrt/third_party/onnx/onnx/tools/net_drawer.py --input ./weights/tiny_3l_v5_11_608.onnx  --output ./weights/tiny_3l_v5_11_608.dot --embed_docstring

Terveisin, Markus

Markus Kaukonen
  • 334
  • 4
  • 10

4 Answers4

5

You can simply use

from onnx import shape_inference
inferred_model = shape_inference.infer_shapes(original_model)

and find the shape info in inferred_model.graph.value_info.

For full doc, see https://github.com/onnx/onnx/blob/master/docs/ShapeInference.md

gizzmole
  • 1,437
  • 18
  • 26
1

Hei,

https://github.com/onnx/onnx-tensorrt has this feature.

I did

onnx2trt yolo_tiny_3l.onnx  -t yolo_tiny_3l.onnx.txt -l -v

Terveisin, Markus

Markus Kaukonen
  • 334
  • 4
  • 10
1

If you are using Java apis to load ONNX model, then get the metadata information from session. Metadata contains the details about input and output dimensions.

Ambuj Kumar
  • 71
  • 1
  • 6
0

Try loading the .onnx file into this online ONNX visualiser tool (Netron)

omatai
  • 3,448
  • 5
  • 47
  • 74