TensorFlow Model Optimization را نصب کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
توصیه می شود قبل از شروع نصب، یک محیط مجازی پایتون ایجاد کنید. لطفاً راهنمای نصب TensorFlow را برای اطلاعات بیشتر ببینید.
ساختمان های پایدار
برای نصب آخرین نسخه، موارد زیر را اجرا کنید:
# Installing with the `--upgrade` flag ensures you'll get the latest version.
pip install --user --upgrade tensorflow-model-optimization
برای جزئیات انتشار، به یادداشتهای انتشار ما مراجعه کنید.
برای نسخه مورد نیاز TensorFlow و سایر اطلاعات سازگاری، به بخش ماتریس سازگاری API در صفحه نمای کلی برای تکنیکی که قصد استفاده از آن را دارید، مراجعه کنید. به عنوان مثال، برای هرس، صفحه نمای کلی اینجا است.
از آنجایی که TensorFlow به عنوان وابستگی بسته بهینه سازی مدل TensorFlow (در setup.py
) گنجانده نشده است، باید به صراحت بسته TensorFlow ( tf-nightly
یا tf-nightly-gpu
) را نصب کنید. این به ما امکان می دهد به جای بسته های جداگانه برای CPU و TensorFlow مجهز به GPU، یک بسته را حفظ کنیم.
نصب از منبع
شما همچنین می توانید از منبع نصب کنید. این به سیستم ساخت 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 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده 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"]]