An Expert Advisor that can recognize handwritten digits
The
The trained handwritten digit recognition model mnist.onnx was downloaded from Github from
int PredictNumber(void) Â Â { Â Â static matrixf image(28,28); Â Â static vectorf result(10); Â Â PrepareMatrix(image); Â Â if(!OnnxRun(ExtModel,ONNX_DEFAULT,image,result)) Â Â Â Â { Â Â Â Â Â Â Print("OnnxRun error ",GetLastError()); Â Â Â Â Â Â return(-1); Â Â Â Â } Â Â result.Activation(result,AF_SOFTMAX); Â Â int predict=int(result.ArgMax()); Â Â if(result[predict]<0.8) Â Â Â Â Â Â Print(result); Â Â Print("value ",predict," predicted with probability ",result[predict]); Â Â return(predict); Â Â }
 Draw digits in a special grid using the mouse, holding down the left mouse button. To recognize the drawn digit, press the CLASSIFY button.
If the obtained probability for the recognized digit is less than 0.8, the resulting vector with probabilities for each class is printed to the log. For example, try classifying an empty unfilled input field.
[0.095331445,0.10048489,0.10673151,0.10274081,0.087865397,0.11471312,0.094342403,0.094900772,0.10847695,0.09441267] value 5 predicted with probability 0.11471312493085861For some reason, the recognition accuracy is notably lower for the number nine (9). Left-slanted digits are recognized more accurately.