ใหม่! ใช้ Simple ML สำหรับชีตเพื่อใช้แมชชีนเลิร์นนิงกับข้อมูลใน Google ชีตของคุณ อ่านเพิ่มเติม

การติดตั้ง

จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ

การติดตั้งด้วย Pip

ติดตั้ง TensorFlow Decision Forests โดยเรียกใช้:

# Install TensorFlow Decision Forests.
pip3 install tensorflow_decision_forests --upgrade

จากนั้นตรวจสอบการติดตั้งโดยเรียกใช้:

# Check the version of TensorFlow Decision Forests.
python3 -c "import tensorflow_decision_forests as tfdf; print('Found TF-DF v' + tfdf.__version__)"

สร้างจากแหล่งที่มา

ลีนุกซ์

ติดตั้ง

ความต้องการ

  • บาเซล >= 3.7.2
  • ไพธอน >= 3
  • คอมไพล์
  • แพ็คเกจ Python: หมีแพนด้าเทนเซอร์โฟลว์จำนวนมาก

แทนที่จะติดตั้งการพึ่งพาด้วยตนเอง คุณสามารถใช้ TensorFlow Build docker หากคุณเลือกตัวเลือกนี้ ให้ติดตั้ง Docker:

การรวบรวม

ดาวน์โหลด TensorFlow Decision Forests ดังนี้:

# Download the source code of TF-DF.
git clone https://github.com/tensorflow/decision-forests.git
cd decision-forests

ทางเลือก: TensorFlow Decision Forests ขึ้นอยู่กับ Yggdrasil Decision Forests หากคุณต้องการแก้ไขรหัส Yggdrasil คุณสามารถโคลน Yggdrasil github และเปลี่ยนเส้นทางตามใน third_party/yggdrasil_decision_forests/workspace.bzl

ทางเลือก: หากคุณต้องการใช้ตัวเลือกนักเทียบท่า ให้รันสคริปต์ start_compile_docker.sh และดำเนินการต่อไปยังขั้นตอนถัดไป หากคุณไม่ต้องการใช้ตัวเลือกนักเทียบท่า ให้ทำตามขั้นตอนถัดไปโดยตรง

# Optional: Install and start the build docker.
./tools/start_compile_docker.sh

รวบรวมและเรียกใช้การทดสอบหน่วยของ TF-DF ด้วยคำสั่งต่อไปนี้ โปรดทราบว่า test_bazel.sh ได้รับการกำหนดค่าสำหรับ python3.8 และคอมไพเลอร์เริ่มต้นในเครื่องของคุณ แก้ไขไฟล์โดยตรงเพื่อเปลี่ยนการกำหนดค่านี้

# Build and test TF-DF.
./tools/test_bazel.sh

สร้างและทดสอบแพ็คเกจ pip ด้วยคำสั่งต่อไปนี้ แทนที่ python3.8 ด้วยเวอร์ชันของ python ที่คุณต้องการใช้ โปรดทราบว่าคุณไม่จำเป็นต้องใช้ Python เวอร์ชันเดียวกับในสคริปต์ test_bazel.sh

หากการกำหนดค่าของคุณเข้ากันได้กับ manylinux2014 จะมีการสร้างแพ็คเกจ pip ที่เข้ากันได้กับ manylinux2014

หากการกำหนดค่าของคุณเข้ากันไม่ได้กับ manylinux2014 จะมีการสร้างแพ็คเกจ pip ที่ไม่รองรับ manylinux2014 และการตรวจสอบขั้นสุดท้ายจะล้มเหลว ไม่สำคัญว่าคุณต้องการใช้ TF-DF บนเครื่องของคุณเองหรือไม่ วิธีง่ายๆ ในการทำให้ build manylinux2014 เข้ากันได้คือการใช้ docker ที่กล่าวถึงข้างต้น

# Build and test a Pip package.
./tools/build_pip_package.sh python3.8

คำสั่งนี้จะติดตั้งแพ็คเกจ pip ของ TF-DF และรันตัวอย่างใน examples/minimal.py แพ็คเกจ Pip อยู่ในไดเร็กทอรี dist/

หากคุณต้องการสร้างแพ็คเกจ Pip สำหรับ Python เวอร์ชันอื่นที่เข้ากันได้ ให้รัน:

# Install the other versions of python (assume only python3.8 is installed; this is the case in the build docker).
sudo apt-get update && sudo apt-get install python3.7 python3.9 python3-pip

# Create the Pip package for the other version of python
./tools/build_pip_package.sh python3.7
./tools/build_pip_package.sh python3.9

หรือ คุณสามารถสร้างแพ็คเกจ pip สำหรับ python เวอร์ชันที่เข้ากันได้ทั้งหมดโดยใช้ pyenv โดยเรียกใช้คำสั่งต่อไปนี้ ดูส่วนหัวของ tools/build_pip_package.sh สำหรับรายละเอียดเพิ่มเติม

# Build and test all the Pip package using Pyenv.
./tools/build_pip_package.sh ALL_VERSIONS

แมคโอเอส

ติดตั้ง

ความต้องการ

  • เครื่องมือบรรทัดคำสั่ง XCode
  • Bazel (แนะนำ Bazelisk )
  • ไพธอน >= 3.8
  • คอมไพล์
  • Pyenv (สำหรับสร้างแพ็คเกจ Pip ด้วย Python หลายเวอร์ชัน)

อาคาร / บรรจุภัณฑ์ (Apple CPU)

หากคุณมีเครื่อง MacOS ที่มี Apple CPU คุณสามารถสร้างด้วยคำแนะนำต่อไปนี้

  1. โคลนที่เก็บสามแห่งและปรับเส้นทาง

    git clone https://github.com/tensorflow/decision-forests.git
    git clone https://github.com/google/yggdrasil-decision-forests.git
    git clone --branch boost-1.75.0 https://github.com/boostorg/boost.git
    (cd boost && git submodule update --init --checkout --force)
    # Adjust path TF-DF --> YDF
    perl -0777 -i.original -pe 's/    http_archive\(\n        name = "ydf",\n        urls = \["https:\/\/github.com\/google\/yggdrasil-decision-forests\/archive\/refs\/heads\/main.zip"\],\n        strip_prefix = "yggdrasil-decision-forests-main",\n    \)/    native.local_repository\(\n        name = "ydf",\n        path = "..\/yggdrasil-decision-forests",\n    \)/igs' decision-forests/third_party/yggdrasil_decision_forests/workspace.bzl
    # Adjust path YDF --> Boost
    perl -0777 -i.original -pe 's/    new_git_repository\(\n        name = "org_boost",\n        branch = branch,\n        build_file_content = build_file_content,\n        init_submodules = True,\n        recursive_init_submodules = True,\n        remote = "https:\/\/github.com\/boostorg\/boost",\n    \)/    native.new_local_repository\(\n        name = "org_boost",\n        path = "..\/boost",\n        build_file_content = build_file_content,\n    \)/igs' yggdrasil-decision-forests/third_party/boost/workspace.bzl
    
  2. (ไม่บังคับ) สร้างสภาพแวดล้อมเสมือนจริงใหม่และเปิดใช้งาน

    python3 -m venv venv
    source venv/source/activate
    
  3. ปรับการพึ่งพา TensorFlow สำหรับ Apple CPU

    perl -0777 -i.original -pe 's/tensorflow~=/tensorflow-macos~=/igs' decision-forests/configure/setup.py
    
  4. เลือกเวอร์ชัน Python ที่คุณต้องการใช้และเรียกใช้

    cd decision-forests
    # This will compile with the latest Tensorflow version in the tensorflow-macos repository.
    RUN_TESTS=1 PY_VERSION=3.9 TF_VERSION=mac-arm64 ./tools/test_bazel.sh
    
  5. สร้างแพ็คเกจ Pip

    # First, we deactivate our virtualenv, since the Pip script uses a different one.
    deactivate
    # Build the packages.
    ./tools/build_pip_package.sh ALL_VERSIONS_MAC_ARM64
    
  6. แพ็คเกจสามารถพบได้ใน decision-forests/dist/

การคอมไพล์ข้ามสำหรับ Intel CPUs

หากคุณมีเครื่อง MacOS ที่ใช้ CPU ของ Apple ให้คอมไพล์ TF-DF ข้ามเครื่องสำหรับเครื่อง MacOS ที่ใช้ CPU ของ Intel ดังนี้

  1. ทำตามขั้นตอนที่ 1-3 และ 5 ของคำแนะนำสำหรับ CPU ของ Apple ข้ามขั้นตอนที่ 4

  2. เลือกเวอร์ชัน Python ที่คุณต้องการใช้และเรียกใช้

    cd decision-forests
    # This will compile with the latest Tensorflow version in the tensorflow-macos repository.
    RUN_TESTS=0 PY_VERSION=3.9 TF_VERSION=mac-intel-crosscompile ./tools/test_bazel.sh
    
  3. สร้างแพ็คเกจ Pip

    # First, we deactivate our virtualenv, since the Pip script uses a different one.
    deactivate
    # Build the packages.
    ./tools/build_pip_package.sh ALL_VERSIONS_MAC_INTEL_CROSSCOMPILE
    
  4. แพ็คเกจสามารถพบได้ใน decision-forests/dist/

หมายเหตุสุดท้าย

การคอมไพล์ TF-DF อาศัยแพ็คเกจ TensorFlow Pip และ การพึ่งพา TensorFlow Bazel จะรวบรวม TensorFlow เพียงส่วนเล็ก ๆ เท่านั้น การคอมไพล์ TF-DF บนเวิร์กสเตชันทรงพลังเครื่องเดียวใช้เวลาประมาณ 10 นาที

การแก้ไขปัญหา