تثبيت نموذج TensorFlow الأمثل
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يوصى بإنشاء بيئة افتراضية لـ Python قبل متابعة التثبيت. يرجى الاطلاع على دليل تثبيت TensorFlow لمزيد من المعلومات.
بنيات مستقرة
لتثبيت الإصدار الأحدث، قم بتشغيل ما يلي:
# Installing with the `--upgrade` flag ensures you'll get the latest version.
pip install --user --upgrade tensorflow-model-optimization
للحصول على تفاصيل الإصدار، راجع ملاحظات الإصدار الخاصة بنا.
للحصول على الإصدار المطلوب من TensorFlow ومعلومات التوافق الأخرى، راجع قسم مصفوفة توافق API في صفحة النظرة العامة للتعرف على التقنية التي تنوي استخدامها. على سبيل المثال، بالنسبة للتقليم، توجد صفحة النظرة العامة هنا .
نظرًا لأن TensorFlow لم يتم تضمينه باعتباره تبعية لحزمة TensorFlow Model Optimization (في setup.py
)، فيجب عليك تثبيت حزمة TensorFlow بشكل صريح ( tf-nightly
أو tf-nightly-gpu
). يتيح لنا ذلك الاحتفاظ بحزمة واحدة بدلاً من الحزم المنفصلة لوحدة المعالجة المركزية ووحدة معالجة الرسومات التي تدعم TensorFlow.
التثبيت من المصدر
يمكنك أيضًا التثبيت من المصدر. وهذا يتطلب نظام بناء Bazel .
# To install dependencies on Ubuntu:
# sudo apt-get install bazel git python-pip
# For other platforms, see Bazel docs above.
git clone https://github.com/tensorflow/model-optimization.git
cd model-optimization
bazel build --copt=-O3 --copt=-march=native :pip_pkg
PKGDIR=$(mktemp -d)
./bazel-bin/pip_pkg $PKGDIR
pip install --user --upgrade $PKGDIR/*.whl
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Install TensorFlow Model Optimization\n\nIt is recommended to create a Python virtual environment before proceeding to\nthe installation. Please see the TensorFlow installation\n[guide](https://www.tensorflow.org/install/pip#2.-create-a-virtual-environment-recommended)\nfor more information.\n\n### Stable Builds\n\nTo install the latest version, run the following: \n\n # Installing with the `--upgrade` flag ensures you'll get the latest version.\n pip install --user --upgrade tensorflow-model-optimization\n\nFor release details, see our\n[release notes](https://github.com/tensorflow/model-optimization/releases).\n\nFor the required version of TensorFlow and other compatibility information, see\nthe API Compatibility Matrix section of the Overview page for the technique you\nintend to use. For instance, for pruning, the Overview page is\n[here](https://www.tensorflow.org/model_optimization/guide/pruning).\n\nSince TensorFlow is *not* included as a dependency of the TensorFlow Model\nOptimization package (in `setup.py`), you must explicitly install the TensorFlow\npackage (`tf-nightly` or `tf-nightly-gpu`). This allows us to maintain one\npackage instead of separate packages for CPU and GPU-enabled TensorFlow.\n\n### Installing from Source\n\nYou can also install from source. This requires the\n[Bazel](https://bazel.build/) build system. \n\n # To install dependencies on Ubuntu:\n # sudo apt-get install bazel git python-pip\n # For other platforms, see Bazel docs above.\n git clone https://github.com/tensorflow/model-optimization.git\n cd model-optimization\n bazel build --copt=-O3 --copt=-march=native :pip_pkg\n PKGDIR=$(mktemp -d)\n ./bazel-bin/pip_pkg $PKGDIR\n pip install --user --upgrade $PKGDIR/*.whl"]]