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
pippackage 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:
sudo apt updatesudo apt install python3-dev python3-pip # Python 3sudo 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 updatebrew install python # Python 3sudo pip3 install --upgrade virtualenv # system-wide install
2. Create a virtual environment.
virtualenv --python python3 "./venv"source "./venv/bin/activate"pip install --upgrade pip
3. Install TensorFlow
CPU support:
pip install 'tensorflow>=1.15.0'GPU support:
pip install 'tensorflow-gpu>=1.15.0'4. Install the Neural Structured Learning pip package.
pip install --upgrade neural_structured_learning5. (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:
sudo apt updatesudo apt install python3-dev python3-pip # Python 3sudo 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 updatebrew install python # Python 3sudo pip3 install --upgrade virtualenv # system-wide install
2. Install Bazel.
Install Bazel, the build tool used to compile Neural Structured Learning.
3. Clone the Neural Structured Learning repository.
git clone https://github.com/tensorflow/neural-structured-learning.git4. Create a virtual environment.
virtualenv --python python3 "./venv"source "./venv/bin/activate"pip install --upgrade pip
5. Install Tensorflow
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'6. Install Neural Structured Learning dependencies.
cd neural-structured-learningpip install --requirement neural_structured_learning/requirements.txt
7. (Optional) Unit Test Neural Structured Learning.
bazel test //neural_structured_learning/...8. Build the pip package.
python setup.py bdist_wheel --universal --dist-dir="./wheel"9. Install the pip package.
pip install --upgrade ./wheel/neural_structured_learning*.whl10. Test Neural Structured Learning.
python -c "import neural_structured_learning as nsl"