but with MC when i return a pointer to the model i got a memory popup error.
here my loading model in c++
Code: Select all
// LOAD NN engine with CPPFLOW
//return model ID for futur call
//engine filename is on dll folder
std::unique_ptr< cppflow::model> __stdcall BinaCpp_loadNN(
char* filename)
{
//loading the model each time causes overload.
//Either you load the model in global scope (outside of any class or main).
//The other option is to create a unique pointer which will be loaded once when first called.
//Declare unique pointer:
auto model = std::make_unique<cppflow::model>(std::string(filename));
return model;
}
Code: Select all
// DLL NAME RETURN VALUE FUNCTION NAME INPUTS
DefineDLLFunc: "BinaApi.dll", int64, "BinaCpp_loadNN",LPSTR; // return int64 for pointer
DefineDLLFunc: "BinaApi.dll", double, "BinaCpp_runNN",int,float,float; // return double int as pointer float as data inputs
//saved engine files are in dll directory
vars: intrabarpersist ModelID(0);
vars: intrabarpersist prediction(0);
vars: intrabarpersist varX(0), intrabarpersist varY(0), intrabarpersist loadNN(0);
vars: heur(""),ret(0);
Once
begin
//load the model in memory
heur=LeftStr(FormatTime("HH:mm:ss:ms",datetime)+" ",14) ;
messagelog(heur,"Load TF Model ... ");
ModelID= BinaCpp_loadNN("C:\Program Files\TS Support\MultiCharts64");
heur=LeftStr(FormatTime("HH:mm:ss:ms",datetime)+" ",14) ;
messagelog(heur,"Load ModelID ",ModelID); //never comming
varX=1; varY=0; //setting inputs
prediction = BinaCpp_runNN(ModelID,varx,vary);
heur=LeftStr(FormatTime("HH:mm:ss:ms",datetime)+" ",14) ;
messagelog(heur,"Prediction ",varx," ",varY," output = ",prediction);
end;