Showing results for 
Search instead for 
Did you mean: 

How to fix "TOOL ERROR: Applying softmax on single element" in X-Cube-AI

Associate II


I am using the X-Cube-AI expansion pack in STM32Cube IDE and wanted to add an ONNX model. After selecting the model and pressing Analyze, I get the error: "TOOL ERROR: Applying softmax on single element".

The model I am trying to use is a neural network created in Scikit-learn and is converted into the ONNX format using skl2onnx. I am using skl2onnx version 1.14.1 and X-Cube-AI version 8.0.1. The project was created for the

Although I am trying to create a neural network for my own data, I am receiving the same error message when using the example for creating a neural network and converting it to the ONNX format. The following is the example code I used in Python:

# Train a model.
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
iris = load_iris()
X, y =,
X_train, X_test, y_train, y_test = train_test_split(X, y)
from sklearn.neural_network import MLPClassifier
clr = MLPClassifier(), y_train)
# Convert into ONNX format
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
initial_type = [('float_input', FloatTensorType([None, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)
with open("rf_iris.onnx", "wb") as f:

Thank you in advance.