Including this article, we will basically use MacOS. If the verified environment is different, describe it as a prerequisite. This article is a neural network library released by Google's DeepMind. I would like to install and implement sonnet.
A neural network library for python released by DeepMind. It is said that the library used in-house has been released as open source. Deep learning is possible with Tensorflow, I wonder if it is positioned to make it easier to do deep learning by wrapping Tensorflow. I personally think. The feature of Sonnet seems to be that it can be mixed and used with Sonnet + Tensorflow. I think there are libraries such as Keras in the sense that Tensorflow works behind the scenes, I'm wondering if it's different from Keras. (It seems that they were officially supported ...?)
I would like to introduce it immediately. From here onward, basically refer to the following URL. https://github.com/deepmind/sonnet
bazel is a build tool released by Google. Since it is a build tool that is required to use Sonnet, Install bazel. Below is the URL of bazel https://bazel.build/ It seems that JDK 8 is required for bazel, so put it in advance.
brew cask install java
After installing the JDK, install bazel.
brew install bazel
I can put the library in Python with the command pip, There is a statement that sonnet should be cloned and installed with git, so clone the sonnet repository with git.
git clone --recursive https://github.com/deepmind/sonnet
It seems that Tensorflow is also cloned when sonnet is cloned with git clone. It seems that it has Tensorflow as a submodule for sonnet, so Operate according to the explanation of github
cd sonnet/tensordlow
./configure
When you configure, the following message will appear, so set it appropriately. This time, I will not use Google Cloud Platform or Hadoop, nor will I use CUDA, so basically I will select N for all Support related items.
Please specify the location of python. [Default is ]:
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N] N
No Hadoop File System support will be enabled for TensorFlow
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] N
No XLA JIT support will be enabled for TensorFlow
Found possible Python library paths:
path
Please input the desired Python library path to use. Default is [path]
Using python library path: path
Do you wish to build TensorFlow with OpenCL support? [y/N] N
No OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N] N
No CUDA support will be enabled for TensorFlow
Configuration finished
You should now have a header file.
Once this is done, build using bazel.
mkdir /tmp/sonnet
bazel build --config=opt :install
Create a location to generate the whl file for installation. Then build using bazel.
INFO: From Linking sonnet/python/gen_resampler_py_wrapper_py_wrappers_cc [for host]:
clang: warning: argument unused during compilation: '-pthread'
Target //:install up-to-date:
bazel-bin/install
INFO: Elapsed time: 704.528s, Critical Path: 667.50s
If such a message appears at the end, it seems that the build is complete.
./bazel-bin/install /tmp/sonnet
pip install /tmp/sonnet/*.whl
This will put sonnet in python.
Make sure sonnet works fine.
>> import sonnet as snt
>> import tensorflow as tf
>> snt.resampler(tf.constant[.0], tf.constant[.0])
At this time, it may not work. The error message I got is like this
error_messege.txt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sonnet/python/ops/resampler.py", line 65, in resampler
raise ImportError("_gen_resampler could not be imported.")
ImportError: _gen_resampler could not be imported.
If you see such a message, uninstall sonnet and then It may work by pip installing sonnet again.