Cài đặt học tập có cấu trúc thần kinh

Có một số cách để thiết lập môi trường của bạn để sử dụng Học tập có cấu trúc thần kinh (NSL) trong TensorFlow:

  • Cách dễ nhất để tìm hiểu và sử dụng NSL không cần cài đặt: chạy hướng dẫn NSL trực tiếp trong trình duyệt của bạn bằng Google Colaboratory .
  • Để sử dụng NSL trên máy cục bộ, hãy cài đặt gói NSL bằng trình quản lý gói pip của Python.
  • Nếu bạn có cấu hình máy duy nhất, hãy xây dựng NSL từ nguồn.

Cài đặt Học tập có cấu trúc thần kinh bằng pip

1. Cài đặt môi trường phát triển Python.

Trên Ubuntu:

sudo apt update
sudo apt install python3-dev python3-pip  # Python 3
sudo pip3 install --upgrade virtualenv  # system-wide install

Trên macOS:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
brew update
brew install python  # Python 3
sudo pip3 install --upgrade virtualenv  # system-wide install

2. Tạo môi trường ảo.

virtualenv --python python3 "./venv"
source "./venv/bin/activate"
pip install --upgrade pip

3. Cài đặt TensorFlow

Hỗ trợ CPU:

pip install 'tensorflow>=1.15.0'

Hỗ trợ GPU:

pip install 'tensorflow-gpu>=1.15.0'

4. Cài đặt gói pip Học tập có cấu trúc thần kinh.

pip install --upgrade neural_structured_learning

5. (Tùy chọn) Kiểm tra việc học theo cấu trúc thần kinh.

python -c "import neural_structured_learning as nsl"

Xây dựng gói pip Học tập có cấu trúc thần kinh

1. Cài đặt môi trường phát triển Python.

Trên Ubuntu:

sudo apt update
sudo apt install python3-dev python3-pip  # Python 3
sudo pip3 install --upgrade virtualenv  # system-wide install

Trên macOS:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
brew update
brew install python  # Python 3
sudo pip3 install --upgrade virtualenv  # system-wide install

2. Cài đặt Bazel.

Cài đặt Bazel , công cụ xây dựng được sử dụng để biên dịch Học tập có cấu trúc thần kinh.

3. Sao chép kho lưu trữ Học tập có cấu trúc thần kinh.

git clone https://github.com/tensorflow/neural-structured-learning.git

4. Tạo môi trường ảo.

virtualenv --python python3 "./venv"
source "./venv/bin/activate"
pip install --upgrade pip

5. Cài đặt Tensorflow

Lưu ý rằng NSL yêu cầu phiên bản TensorFlow từ 1.15 trở lên. NSL cũng hỗ trợ TensorFlow 2.0.

Hỗ trợ CPU:

pip install 'tensorflow>=1.15.0'

Hỗ trợ GPU:

pip install 'tensorflow-gpu>=1.15.0'

6. Cài đặt các phần phụ thuộc Học tập có cấu trúc thần kinh.

cd neural-structured-learning
pip install --requirement neural_structured_learning/requirements.txt

7. (Tùy chọn) Bài kiểm tra đơn vị Học tập theo cấu trúc thần kinh.

bazel test //neural_structured_learning/...

8. Xây dựng gói pip.

python setup.py bdist_wheel --universal --dist-dir="./wheel"

9. Cài đặt gói pip.

pip install --upgrade ./wheel/neural_structured_learning*.whl

10. Kiểm tra việc học theo cấu trúc thần kinh.

python -c "import neural_structured_learning as nsl"