Samples of ONNX export
How do I create ONNX files?
Below, several ways of exporting certain models as ONNX from different frameworks are shown using examples. The samples do not claim to be complete and only serve to provide a primary overview. For more detailed documentation, refer to the documentation for the respective framework.
The listed examples are limited to the creation of an ONNX file. Examples for conversion to make the file available in TwinCAT can be found here: Converting ONNX to XML and BML as well as in the ZIP archive for the linked samples (see below) in the PythonAPI_mllib folder.
Overview of available samples
Python package | Model type | Option | Comment | Sample link |
---|---|---|---|---|
PyTorch | MLP Regressor |
|
| |
Keras | MLP Regressor |
|
| |
Scikit-learn | MLP Regressor |
|
| |
Scikit-learn | MLP Classifier |
| ONNX graph must be adapted | |
Scikit-learn | SVR |
|
| |
Scikit-learn | SVC | decision_function_shape='ovo' |
| |
Scikit-learn | k-means |
| Meta Key must be entered in ONNX. | |
Scikit-learn | PCA |
|
| |
Scikit-learn | Decision Tree Classifier |
|
| |
Scikit-learn | Decision Tree Regressor |
|
| |
Scikit-learn | Extra Tree Classifier |
|
| |
Scikit-learn | Extra Tree Regressor |
|
| |
Scikit-learn | Extra Trees Classifier |
|
| |
Scikit-learn | Extra Trees Regressor |
|
| |
Scikit-learn | Random Forest Classifier |
|
| |
Scikit-learn | Random Forest Regressor |
|
| |
LightGBM | Random Forest Regressor |
| ONNX graph must be adapted | |
Scikit-learn | Gradient Boosting Classifier |
|
| |
Scikit-learn | Gradient Boosting Regressor |
|
| |
Scikit-learn | Hist Gradient Boosting Classifier |
|
| |
Scikit-learn | Hist Gradient Boosting Regressor |
|
| |
XGBoost | XGBClassifier | Not all configurations allow an ONNX export | Package version <= 1.5.2 or >= 1.7.4 required | |
XGBoost | XCBRegressor | Not all configurations allow an ONNX export | Package version <= 1.5.2 or >= 1.7.4 required | |
LightGBM | LGBMRegressor | Not all configurations allow an ONNX export |
| |
LightGBM | LGBMClassifier |
| ONNX graph must be adapted |
All samples can be downloaded here as a ZIP archive: Beckhoff_ONNX_Samples.zip