0Pricing
MLOps Academy · درس

التصدير إلى ONNX لإتاحة النقل

انقل النموذج بين أطر العمل وبيئات التشغيل.

التصدير إلى ONNX لإتاحة النقل درس مجاني في MLOps Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MLOps Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MLOps Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

The Portability Problem

You trained in PyTorch but want to serve in C++ or the browser. A framework-locked file makes that painful. ONNX fixes it. 🌍

What ONNX Is

ONNX is an open, shared format for models. It describes the math as a graph that many frameworks and runtimes can read.

A Graph of Operators

Under the hood an ONNX model is a graph of standard operators like MatMul and Relu, plus the learned weights.

Train Once, Run Anywhere

Export once and the same file runs on servers, mobile, and edge devices through different runtimes, no retraining needed.

Export from PyTorch

PyTorch ships an exporter. You pass the model and a sample input to torch.onnx.export so it can trace the graph.

import torch
torch.onnx.export(model, sample, 'model.onnx')

Why a Sample Input?

The exporter runs your model on the sample to record which ops fire. That traced run becomes the graph it saves.

Convert from sklearn

For scikit-learn use the skl2onnx library. You give it the model and the input shape to produce an ONNX graph.

from skl2onnx import to_onnx
onx = to_onnx(model, X[:1])

Run with ONNX Runtime

ONNX Runtime is a fast, cross-platform engine. You load the .onnx file into a session and call run to get predictions.

import onnxruntime as ort
sess = ort.InferenceSession('model.onnx')

Speed and Hardware

ONNX Runtime can use execution providers like CUDA or TensorRT to accelerate the same model on different hardware. ⚡

Opset Versions

Each export targets an opset version that defines available operators. Match it to what your runtime supports, or loading fails.

Always Verify Outputs

After export, run both models on the same input and compare. Confirm the ONNX result matches the original before you ship it. ✅

Quick Check

Let's see how well you understand ONNX.

Recap

You can export models to ONNX, run them with ONNX Runtime on any hardware, mind the opset, and always verify outputs match. 🎉

الأسئلة الشائعة

هل درس «التصدير إلى ONNX لإتاحة النقل» مجاني؟

نعم — نص درس «التصدير إلى ONNX لإتاحة النقل» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة MLOps Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MLOps Academy 4 دروس في المجموع.

ماذا ستتعلم في «التصدير إلى ONNX لإتاحة النقل»؟

انقل النموذج بين أطر العمل وبيئات التشغيل. تتمرن على MLOps Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ MLOps Academy؟

لا تُشترط خبرة سابقة. MLOps Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «التصدير إلى ONNX لإتاحة النقل»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس MLOps Academy هذا؟

نعم. كل درس في MLOps Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. التسلسل باستخدام Pickle وJoblib
  2. صيغة نموذج MLflow
  3. التصدير إلى ONNX لإتاحة النقل
  4. تحديد توقيع النموذج ومخططه
← العودة إلى MLOps Academy