Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Có một số cách để thiết lập môi trường của bạn để sử dụng TensorFlow Federated (TFF):
Cách dễ nhất để tìm hiểu và sử dụng TFF không cần cài đặt; chạy các hướng dẫn liên kết TensorFlow trực tiếp trong trình duyệt của bạn bằng cách sử dụng Google Colaboratory .
Để sử dụng TensorFlow Federated trên máy cục bộ, hãy cài đặt gói TFF bằng trình quản lý gói pip của Python.
3. Cài đặt gói Python liên kết TensorFlow đã phát hành.
pipinstall--upgradetensorflow-federated
4. Kiểm tra liên kết Tensorflow.
python-c"import tensorflow_federated as tff; print(tff.tensorflow_computation(lambda: 'Hello World')())"
Xây dựng gói Python liên kết TensorFlow từ nguồn
Xây dựng gói Python liên kết TensorFlow từ nguồn rất hữu ích khi bạn muốn:
Thực hiện các thay đổi đối với TensorFlow Federated và kiểm tra những thay đổi đó trong thành phần sử dụng TensorFlow Federated trước khi những thay đổi đó được gửi hoặc phát hành.
Sử dụng các thay đổi đã được gửi tới TensorFlow Federated nhưng chưa được phát hành.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["# Install TensorFlow Federated\n\n\u003cbr /\u003e\n\nThere are a few ways to set up your environment to use TensorFlow Federated\n(TFF):\n\n- The easiest way to learn and use TFF requires no installation; run the TensorFlow Federated tutorials directly in your browser using [Google Colaboratory](https://colab.research.google.com/notebooks/welcome.ipynb).\n- To use TensorFlow Federated on a local machine, [install the TFF package](#install_tensorflow_federated_using_pip) with Python's `pip` package manager.\n- If you have a unique machine configuration, [build the TFF package from source](#build_the_tensorflow_federated_python_package_from_source) .\n\nInstall TensorFlow Federated using `pip`\n----------------------------------------\n\n### 1. Install the Python development environment.\n\n sudo apt update\n sudo apt install python3-dev python3-pip # Python 3\n\n### 2. Create a virtual environment.\n\n python3 -m venv \"venv\"\n source \"venv/bin/activate\"\n pip install --upgrade \"pip\"\n\n| **Note:** To exit the virtual environment, run `deactivate`.\n\n### 3. Install the released TensorFlow Federated Python package.\n\n pip install --upgrade tensorflow-federated\n\n### 4. Test Tensorflow Federated.\n\n python -c \"import tensorflow_federated as tff; print(tff.tensorflow_computation(lambda: 'Hello World')())\"\n\n| **Success:** The latest TensorFlow Federated Python package is now installed.\n\nBuild the TensorFlow Federated Python package from source\n---------------------------------------------------------\n\nBuilding a TensorFlow Federated Python package from source is helpful when you\nwant to:\n\n- Make changes to TensorFlow Federated and test those changes in a component that uses TensorFlow Federated before those changes are submitted or released.\n- Use changes that have been submitted to TensorFlow Federated but have not been released.\n\n### 1. Install the Python development environment.\n\n sudo apt update\n sudo apt install python3-dev python3-pip # Python 3\n\n### 2. Install Bazel.\n\n[Install Bazel](https://docs.bazel.build/versions/master/install.html), the\nbuild tool used to compile Tensorflow Federated.\n\n### 3. Clone the Tensorflow Federated repository.\n\n git clone https://github.com/google-parfait/tensorflow-federated.git\n cd \"tensorflow-federated\"\n\n### 4. Create a virtual environment.\n\n python3 -m venv \"venv\"\n source \"venv/bin/activate\"\n pip install --upgrade \"pip\"\n pip install numpy\n\n### 5. Build the TensorFlow Federated Python package.\n\n mkdir \"/tmp/tensorflow_federated\"\n bazel run //tools/python_package:build_python_package -- \\\n --output_dir=\"/tmp/tensorflow_federated\"\n\n### 6. Exit the virtual environment\n\n deactivate\n\n### 7. Create a new project.\n\n mkdir \"/tmp/project\"\n cd \"/tmp/project\"\n\n### 8. Create a new virtual environment.\n\n python3 -m venv \"venv\"\n source \"venv/bin/activate\"\n pip install --upgrade \"pip\"\n\n| **Note:** To exit the virtual environment, run `deactivate`.\n\n### 9. Install the TensorFlow Federated Python package.\n\n pip install --upgrade \"/tmp/tensorflow_federated/\"*\".whl\"\n\n### 10. Test Tensorflow Federated.\n\n python -c \"import tensorflow_federated as tff; print(tff.tensorflow_computation(lambda: 'Hello World')())\"\n\n| **Success:** A TensorFlow Federated Python package is now built from source and installed."]]