Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tensorflow
GitHub Repository: tensorflow/docs-l10n
Path: blob/master/site/pt-br/neural_structured_learning/install.md
25115 views

Instale o Neural Structured Learning

Há várias maneiras de configurar seu ambiente para usar o Neural Structured Learning (NSL) no TensorFlow:

  • A maneira mais fácil de aprender e usar o NSL não requer instalação: basta executar os tutoriais NSL diretamente no seu navegador usando o Google Colaboratory.

  • Para usar o NSL numa máquina local, instale o pacote NSL com o gerenciador de pacotes pip do Python.

  • Se você tiver uma configuração de máquina exclusiva, compile o NSL a partir do código-fonte.

Observação: o NSL requer uma versão 1.15 do TensorFlow ou superior. O NSL também suporta o TensorFlow 2.x, com exceção da v2.1, que contém um bug incompatível com o NSL.

Instale o Neural Structured Learning usando o pip

1. Instale o ambiente de desenvolvimento Python.

No Ubuntu:

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

No 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. Crie um ambiente virtual.

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

Observação: Para sair do ambiente virtual, execute deactivate.

3. Instale o TensorFlow

Suporte de CPU:

pip install 'tensorflow>=1.15.0'

Suporte de GPU:

pip install 'tensorflow-gpu>=1.15.0'

4. Instale o pacote pip do Neural Structured Learning.

pip install --upgrade neural_structured_learning

5. (Opcional) Teste o Neural Structured Learning.

python -c "import neural_structured_learning as nsl"

Sucesso: o Neural Structured Learning já está instalado.

Compile o pacote pip do Neural Structured Learning

1. Instale o ambiente de desenvolvimento Python.

No Ubuntu:

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

No 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. Instale o Bazel.

Instale o Bazel, a ferramenta de build usada para compilar o Neural Structured Learning.

3. Clone o repositório do Neural Structured Learning.

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

4. Crie um ambiente virtual.

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

Observação: Para sair do ambiente virtual, execute deactivate.

5. Instale o Tensorflow

Observe que o NSL requer uma versão 1.15 do TensorFlow ou superior. O NSL também suporta o TensorFlow 2.0.

Suporte de CPU:

pip install 'tensorflow>=1.15.0'

Suporte de GPU:

pip install 'tensorflow-gpu>=1.15.0'

6. Instale as dependências do Neural Structured Learning.

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

7. (Opcional) Rode os testes unitários do Neural Structured Learning.

bazel test //neural_structured_learning/...

8. Compile o pacote pip.

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

9. Instale o pacote pip.

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

10. Teste o Neural Structured Learning.

python -c "import neural_structured_learning as nsl"

Sucesso: O pacote Neural Structured Learning foi compilado.