- ONNX 지원
- 포맷 변환
- 자동 데이터 유형 변환
- 모델 생성
- 모델 실행
- 전략 테스터에서 실행
- OnnxCreate
- OnnxCreateFromBuffer
- OnnxRelease
- OnnxRun
- OnnxGetInputCount
- OnnxGetOutputCount
- OnnxGetInputName
- OnnxGetOutputName
- OnnxGetInputTypeInfo
- OnnxGetOutputTypeInfo
- OnnxSetInputShape
- OnnxSetOutputShape
- 데이터 구조
모델 실행
MQL5에서 ONNX 모델을 실행하려면 다음과 같은 3단계를 거치세요:
- 다음을 사용하여 *.onnx 파일에서 모델을 로드합니다.OnnxCreate 함수 또는 배열OnnxCreateFromBuffer.
- 다음을 사용하여 입력 및 출력 데이터 쉐이프 지정OnnxSetInputShape와OnnxSetOutputShape 함수.
- OnnxRun함수를 사용하여 모델을 실행합니다. 관련 입력 및 출력 매개변수에 전달합니다.
- 필요한 경우 다음을 사용하여 모델 작업을 종료할 수 있습니다.OnnxRelease 함수.
ONNX 모델을 생성할 때 https://github.com/microsoft/onnxruntime/blob/rel-1.14.0/docs/OperatorKernels.md에 설명된 현재 제한 사항 및 금지 사항을 고려해야 합니다.
이러한 제한 사항의 일부 예는 다음과 같습니다:
Operation |
지원되는 데이터 유형 |
---|---|
ReduceSum |
tensor(double), tensor(float), tensor(int32), tensor(int64) |
Mul |
tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64), tensor(uint32), tensor(uint64) |
아래는 공개 프로젝트의 MQL5 코드 예제입니다.ONNX.Price.Prediction.
const long ExtOutputShape[] = {1,1}; // 모델의 출력 쉐이프
|
스크립트 실행 예:
ONNX: Creating and using per session threadpools since use_per_session_threads_ is true
|
MetaTrader 5 터미널은 계산을 위한 최적의 executor를 선택했습니다 —ONNX Runtime Execution Provider. 이 예에서 모델은 CPU에서 실행되었습니다.
이전 10개 바의 값을 기반으로 괜찮은 레벨의 종가 예측의 백분율을 계산하도록 스크립트를 수정해 보겠습니다.
#resource "Python/model.onnx" as uchar ExtModel[]// 자원으로서의 모델
|
스크립트 실행: 예측 정확도는 약 51%입니다.
ONNX: Creating and using per session threadpools since use_per_session_threads_ is true
|