Install Neural Structured Learning

There are several ways to set up your environment to use Neural Structured Learning (NSL) in TensorFlow:

  • The easiest way to learn and use NSL requires no installation: run the NSL tutorials directly in your browser using Google Colaboratory.
  • To use NSL on a local machine, install the NSL package with Python's pip package manager.
  • If you have a unique machine configuration, build NSL from source.

Install Neural Structured Learning using pip

1. Install the Python development environment.

On Ubuntu:

sudoaptupdate
sudoaptinstallpython3-devpython3-pip# Python 3
sudopip3install--upgradevirtualenv# system-wide install

On macOS:

/usr/bin/ruby-e"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"
exportPATH="/usr/local/bin:/usr/local/sbin:$PATH"
brewupdate
brewinstallpython# Python 3
sudopip3install--upgradevirtualenv# system-wide install

2. Create a virtual environment.

virtualenv--pythonpython3"./venv"
source"./venv/bin/activate"
pipinstall--upgradepip

3. Install TensorFlow

CPU support:

pipinstall'tensorflow>=1.15.0'

GPU support:

pipinstall'tensorflow-gpu>=1.15.0'

4. Install the Neural Structured Learning pip package.

pipinstall--upgradeneural_structured_learning

5. (Optional) Test Neural Structured Learning.

python-c"import neural_structured_learning as nsl"

Build the Neural Structured Learning pip package

1. Install the Python development environment.

On Ubuntu:

sudoaptupdate
sudoaptinstallpython3-devpython3-pip# Python 3
sudopip3install--upgradevirtualenv# system-wide install

On macOS:

/usr/bin/ruby-e"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"
exportPATH="/usr/local/bin:/usr/local/sbin:$PATH"
brewupdate
brewinstallpython# Python 3
sudopip3install--upgradevirtualenv# system-wide install

2. Install Bazel.

Install Bazel, the build tool used to compile Neural Structured Learning.

3. Clone the Neural Structured Learning repository.

gitclonehttps://github.com/tensorflow/neural-structured-learning.git

4. Create a virtual environment.

virtualenv--pythonpython3"./venv"
source"./venv/bin/activate"
pipinstall--upgradepip

5. Install Tensorflow

Note that NSL requires a TensorFlow version of 1.15 or higher. NSL also supports TensorFlow 2.0.

CPU support:

pipinstall'tensorflow>=1.15.0'

GPU support:

pipinstall'tensorflow-gpu>=1.15.0'

6. Install Neural Structured Learning dependencies.

cdneural-structured-learning
pipinstall--requirementneural_structured_learning/requirements.txt

7. (Optional) Unit Test Neural Structured Learning.

bazeltest//neural_structured_learning/...

8. Build the pip package.

pythonsetup.pybdist_wheel--universal--dist-dir="./wheel"

9. Install the pip package.

pipinstall--upgrade./wheel/neural_structured_learning*.whl

10. Test Neural Structured Learning.

python-c"import neural_structured_learning as nsl"

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2021年01月28日 UTC.