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.
Note: NSL requires a TensorFlow version of 1.15 or higher. NSL also supports TensorFlow 2.x with the exception of v2.1, which contains a bug that is incompatible with NSL.
On Ubuntu:
sudo apt update
sudo apt install python3-dev python3-pip # Python 3
sudo pip3 install --upgrade virtualenv # system-wide install
On 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
virtualenv --python python3 "./venv"
source "./venv/bin/activate"
pip install --upgrade pip
Note: To exit the virtual environment, run deactivate
.
CPU support:
pip install 'tensorflow>=1.15.0'
GPU support:
pip install 'tensorflow-gpu>=1.15.0'
pip install --upgrade neural_structured_learning
python -c "import neural_structured_learning as nsl"
Success: Neural Structured Learning is now installed.
On Ubuntu:
sudo apt update
sudo apt install python3-dev python3-pip # Python 3
sudo pip3 install --upgrade virtualenv # system-wide install
On 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
Install Bazel, the build tool used to compile Neural Structured Learning.
git clone https://github.com/tensorflow/neural-structured-learning.git
virtualenv --python python3 "./venv"
source "./venv/bin/activate"
pip install --upgrade pip
Note: To exit the virtual environment, run deactivate
.
Note that NSL requires a TensorFlow version of 1.15 or higher. NSL also supports TensorFlow 2.0.
CPU support:
pip install 'tensorflow>=1.15.0'
GPU support:
pip install 'tensorflow-gpu>=1.15.0'
cd neural-structured-learning
pip install --requirement neural_structured_learning/requirements.txt
bazel test //neural_structured_learning/...
python setup.py bdist_wheel --universal --dist-dir="./wheel"
pip install --upgrade ./wheel/neural_structured_learning*.whl
python -c "import neural_structured_learning as nsl"
Success: The Neural Structured Learning package is built.