New MetaTrader 5 build 3620: Web Terminal improvements, ONNX support and fast matrix multiplications in MQL5 - page 3

 

Hello,

I'm in trouble to get the ONNX output of my model.

Here is the structure of the model :

And my code:

In the init section I have:

  const long output_shape[] = {1};
   if(!OnnxSetOutputShape(ExtHandle,0,output_shape))
     {
      Print("OnnxSetOutputShape error ",GetLastError());
    return(INIT_FAILED);}

And into the processing output funcion that runs the ONNX model:

 static vector output2= vector::Zeros(2);
  vector output1(1);

  
   
              // vector to get result
   vectorf x_norm(SAMPLE_SIZE);       // vector for prices normalize

//--- check for normalization possibility
   if(ExtMin>=ExtMax)
     {
      Print("ExtMin>=ExtMax");
      ExtPredictedClass=-1;
      return;
     }
//--- request last bars
   if(!x_norm.CopyRates(_Symbol,_Period,COPY_RATES_CLOSE,1,SAMPLE_SIZE))
     {
      Print("CopyRates ",x_norm.Size());
      ExtPredictedClass=-1;
      return;
     }
   float last_close=x_norm[SAMPLE_SIZE-1];
//--- normalize prices
   x_norm-=ExtMin;
   x_norm/=(ExtMax-ExtMin);
//--- run the inference
   if(!OnnxRun(ExtHandle,0,x_norm,output1,output2))//,output2[0],output2[1]))
     {
      Print("OnnxRun");
      ExtPredictedClass=-1;
      return;
     }

I get error about the shape of tensor. I spent hours trying to debug but no success.
I'd like to get the probabilities for the -1 / 1 class or the class itself.


Thank you for your help!

Files:
Experts.zip  122 kb