Robots in Space

The term “Artificial Intelligence (AI)” comprises all techniques that enable computers to mimic intelligence, for example, computers that analyse data or the systems embedded in an autonomous vehicle. Usually, artificially intelligent systems are taught by humans — a process that involves writing an awful lot of complex computer code.

Nice little overview of the current initiatives and projects regarding Artificial Intelligence in Space at ESA. Lot’s of interesting stuff going on there. I am personally super excited about autonomous robots and using deep learning for navigation and docking of spacecraft.

Could machine learning mean the end of understanding in science?

If prediction is in fact the primary goal of science, how should we modify the scientific method, the algorithm that for centuries has allowed us to identify errors and correct them?

Interesting piece by UofT’s Amar Vutha on how machine learning is reshaping the scientific landscape. I fundamentally disagree that the goal of science is predicting nature. Predicting is great for applied problems like weather-forecasting, but neglecting the understanding of things bears a great risk, because then the scientific method is basically reduced to guessing what the next step could be and is no longer effective at iterating towards a fundamental truth. With all due respect, let’s leave that “goal-oriented” approach to problem solvers and engineering.

Scientists plan to establish a European Lab for Learning & Intelligent Systems

Today leading scientists in Europe have designated a plan for a multinational European Artificial Intelligence Institute.

ELLIS will be a top employer in machine intelligence research, on par with Berkeley, Stanford, CMU, and MIT. It will also be a world class venue to get trained in the field: in conjunction with universities, it will develop a highly attractive European PhD program, and it will strive to retain the best graduates within ELLIS to groom them into the next generation of senior scientists.

Europe will be able to play a major role in the scientific and societal revolution that is underway.

Although some people may argue that it is already too late, I think it is worthwhile to put the effort and money into it.

Also Ian Sample from The Guardian wrote an interesting article about the development.

Building Tensorflow from Sources on Your MacBook

This guide is inspired by the tremendous walkthrough on TechPolyMath. It walks through building and installing the TensorFlow binary from source on a macOS system. Mostly I am publishing this also as a reference for myself but others might find it useful

The following assumptions were made, using a 2016 MacBook Pro:

  • macOS High Sierra
  • Intel Core i5 Processor
  • TensorFlow 1.4.1
  • Python 3.6.2
  • JDK 8u151
  • Bazel 0.5.4

Note that the resulting binary we build will be optimized for CPU support only.

Installing Prerequisites on macOS

Install Java Development Kit

At the time of publication, Bazel required the Java Development Kit 8.0. If it is not already installed follow these steps.

  • Download the DMG image that containers the JDK installer from Oracle’s Java SE Development Kit 8 Downloads page.
  • The file should be named something like jdk-8u151-macosx-x64.dmg
  • Mount the DMG image, double-click the installer, and follow the guided prompts.

Install Dependencies with Anaconda

It is strongly recommended that you use a virtualenv or Conda environment to isolate the packages and installation of TensorFlow from source. This enables you to maintain multiple combinations of package versions for various projects or experiments.

Since I use Anaconda, I created a new environment by executing the command conda create -n tensorflow python=3.6

Install Bazel

Instead of using the popular Homebrew System, I used anaconda. Basically I wanted to get by with as few tools as possible and since I am a Macports user I tried to avoid homebrew. You can refer to the Bazel documentation for alternatives.

  • From a Terminal, change into your newly created environment source activate tensorflow
  • Use anaconda search bazel to get the right version from conda-forge
  • Install using conda install --channel  https://conda.anaconda.org/c3i_test2 bazel
  • Confirm Bazel is installing by verifying the output of bazel version

I ran into a weird bug, where tensorflow wouldn’t compile with the conda-forge version of bazel 0.8.1, so had to use the next best version available.

Install Python Dependencies

TensorFlow requires the following Python packages:

  • six
  • NumPy
  • wheel

If these are not present on your machine or current environment execute the following to install:

pip3 install six numpy wheel</code>  <h3>Prepare the TensorFlow Installation</h3>  <h5>Clone the TensorFlow Repository</h5>  Now, clone the latest TensorFlow repository to some place on your computer by issuing the following command:  <code> git clone https://github.com/tensorflow/tensorflow

This will take a short while depending on your Internet connection bandwidth due to the repository’s size (~250 MB).

Most of the time you want install a release version rather than trunk. You can display the available releases and check out one using the following commands (example is TensorFlow release 1.4, since it is the newest release):

git branch -l --remote </code>  <code> git checkout r1.4

Configure and Build the TensorFlow pip Package

Frank Hinek from TechPolyMath posted a script that is based on the work of Sasha Nikiforov and a Stackoverflow post with a few minor modifications to support Anaconda environments.

Clone the build_tf.sh script gist to the same directory containing the TensorFlow source:

curl -O https://gist.githubusercontent.com/frankhinek/ \  20f8086d70886c56405fe4431f998ac4/raw/  \ 98c2ea1570d35bf20c0761390eb6d423ea387b02/build_tf.sh</code>  Now, make the script executable:  <code> chmod u+x build_tf.sh

Execute the script to configure and build the TensorFlow pip package using all of the CPU optimizations available for your CPU:

./build_tf.sh</code>  During the TensorFlow configuration process, accept all the defaults by pressing the Enter key repeatedly until the configuration is complete unless you have a specific need.  This build process will take some time to complete. In my experience it averages around 30 minutes, but a system with more than 16GB of RAM will compile faster.  The script will build a .whl file and store it in the /tmp/tensorflow_pkg directory.  <h3>Installing TensorFlow</h3>  The final step is to install the custom-built TensorFlow binary using the wheel file. The specific name of the while will vary depending on the version of TensorFlow and Python in your environment.  In my case, the command to install is:  <code> pip install /tmp/tensorflow_pkg/tensorflow-1.4.1-cp36-cp36m-macosx_10_7_x86_64.whl

Verify Installation

The last step is to confirm that TensorFlow is now installed and working as expected. Before proceeding be sure that you change to a directory other than the one that contains the TensorFlow source tree. We want to import the pip installed package and not the one in the source directory.

Launch the python interactive shell and execute the following commands:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello)

If the system outputs the following, then TensorFlow is installed and working:
Hello, TensorFlow!

Uninstall everything you don’t need anymore

JDK8

Take a look at this nice page documenting how you get rid of all traces of Java by Oracle: Uninstall Java, Uninstall Java JDK

Conda Dependencies

conda uninstall openjdk
conda uninstall bazel
conda uninstall libcxx
conda uninstall libcxxabi

Tensorflow git Repository

sudo rm -rf tensorflow

And finally you’re done, have fun with your newly compiled and optimized tensorflow on your Macbook. As you will probably notice it’s somewhat faster now. Personally I wonder if MPI support would make any difference on the Macbook, so maybe I try that next.