onnx图,如何获取输出维度?

Mar*_*nen 6 python-3.x onnx

如何获取onnx神经网络输出层的维度?

我可以得到 onnx 图,但没有输出尺寸:

~/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
Run Code Online (Sandbox Code Playgroud)

特尔维辛,马库斯

giz*_*ole 5

你可以简单地使用

from onnx import shape_inference
inferred_model = shape_inference.infer_shapes(original_model)
Run Code Online (Sandbox Code Playgroud)

并在 中找到形状信息inferred_model.graph.value_info

有关完整文档,请参阅https://github.com/onnx/onnx/blob/master/docs/ShapeInference.md


Mar*_*nen 1

嘿,

https://github.com/onnx/onnx-tensorrt 有这个功能。

我做到了

onnx2trt yolo_tiny_3l.onnx  -t yolo_tiny_3l.onnx.txt -l -v
Run Code Online (Sandbox Code Playgroud)

特尔维辛,马库斯