Skip to content
All library documents

Inspecting ONNX Model Input and Output Shapes in MQL5

Article MQL5 code base

Summary

This technical note explains how an MQL5 script can inspect an ONNX model’s inputs and outputs before running inference. It retrieves each input and output count, name, and type information, then reports tensor data types and dimensions. The example uses a handwritten digit recognition model and shows that its input and output shapes may be reducible by omitting leading batch dimensions.

The note emphasizes that the model’s input and output shapes must be set for the ONNX run function. Models with dynamic dimensions may not provide fixed sizes, in which case the described script returns an error indicator. The example is for model integration and diagnostics rather than a trading method; it provides no trading results, validation procedure, or guidance on whether an ONNX model is suitable for market prediction.

Key ideas

  • The ONNX run function requires input and output shapes to be specified.
  • A script can query model input and output counts, names, and type information.
  • The example reports tensor data types and dimensions for a digit recognition model.
  • Models with dynamic dimensions may lack fixed sizes required by this workflow.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.