당사 팬 페이지에 가입하십시오
- 조회수:
- 3122
- 평가:
- 게시됨:
- 2023.03.27 12:11
- 업데이트됨:
- 2023.08.25 08:52
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
The ONNX model run function requires the model's input and output sizes to be defined. The sizes are specified via the OnnxSetInputShape and OnnxSetOutputShape functions, respectively.
Not all models have fixed input and output data sizes. In these cases, the script will return -1.
OnnxTypeInfo type_info; long input_count=OnnxGetInputCount(session_handle); Print("model has ",input_count," input(s)"); for(long i=0; i<input_count; i++) { string input_name=OnnxGetInputName(session_handle,i); Print(i," input name is ",input_name); if(OnnxGetInputTypeInfo(session_handle,i,type_info)) PrintTypeInfo(i,"input",type_info); } long output_count=OnnxGetOutputCount(session_handle); Print("model has ",output_count," output(s)"); for(long i=0; i<output_count; i++) { string output_name=OnnxGetOutputName(session_handle,i); Print(i," output name is ",output_name); if(OnnxGetOutputTypeInfo(session_handle,i,type_info)) PrintTypeInfo(i,"output",type_info); }
Use the FileSelectDialog function to select a model from the MQL5\Files folder
An example of how the script runs is shown below:
Create model from mnist.onnx with debug logs ONNX: Creating and using per session threadpools since use_per_session_threads_ is true ONNX: Dynamic block base set to 0 ONNX: Initializing session. ONNX: Adding default CPU execution provider. ONNX: Removing initializer 'Parameter6'. It is no longer used by any node. ONNX: Removing initializer 'Parameter88'. It is no longer used by any node. ONNX: Total shared scalar initializer count: 0 ONNX: Removing initializer 'Parameter193_reshape1_shape'. It is no longer used by any node. ONNX: Removing initializer 'Parameter193'. It is no longer used by any node. ONNX: Total fused reshape node count: 0 ONNX: Total shared scalar initializer count: 0 ONNX: Total fused reshape node count: 0 ONNX: Removing initializer 'Parameter5'. It is no longer used by any node. ONNX: Removing initializer 'Parameter87'. It is no longer used by any node. ONNX: Use DeviceBasedPartition as default ONNX: Saving initialized tensors. ONNX: Done saving initialized tensors ONNX: Session successfully initialized. model has 1 input(s) 0 input name is Input3 type ONNX_TYPE_TENSOR data type ONNX_DATA_TYPE_FLOAT shape [1, 1, 28, 28] shape of input data can be reduced to [28, 28] model has 1 output(s) 0 output name is Plus214_Output_0 type ONNX_TYPE_TENSOR data type ONNX_DATA_TYPE_FLOAT shape [1, 10] shape of output data can be reduced to [10]
Update: Due to the fact that the OnnxTypeInfo structure was changed in build 3700, the source code of the script has been modified.
MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/43452
![Get info about inputs and outputs of onnx-model](https://c.mql5.com/i/code/script.png)
Script gets information about input and output tensors of onnx-model, their types and shapes
![EA Frame](https://c.mql5.com/i/code/expert.png)
Official example involve complex wrapper classes, Here is a simple one
![Time Left To New Bar Watch](https://c.mql5.com/i/code/script.png)
Time Left To New Bar Watch
![send a trade position to telegram channel](https://c.mql5.com/i/code/script.png)
hi, this code need your telegram token and telegram chat id . you can make robot by BotFather and then search in google how you can find telegram token and chat id then attach them to this code . now every trade would be signals on your telegram channel.