A Broad Spectrum of TensorFlow APIs Inside and Outside the Project
TensorFlow APIs for different languages
Since its launch in 2015, TensorFlow has grown into a major player on the machine learning scene. Being actively developed, the tool now offers a bunch of stable low-level APIs with some high-level ones being implemented at a rapid pace.
In his webinar, Aaron Schumacher of Deep Learning Analytics toured through the diversity of APIs available in TensorFlow.
So, there are quite a few APIs for various programming languages.
- The C API is mainly utilized in case one needs to build an API for some other language.
- The C++ API is still somewhat experimental and can be employed in a number of deployment scenarios one chooses. It is exposed via header files in tensorflow/cc. (Note that TensorFlow runtime is written in C++.)
- The Python API is probably the most developed API at the moment with handful of features to enjoy.
- The R API—developed by RStudio—wraps the Python API, thus granting access to all its features, which would be more laboursome experience if enabling replication via the C API.
Furthermore, there are APIs for Java, Go, Rust, Haskell, and unofficial ones—designed outside the core TensorFlow project—for C# and Julia.
APIs inside TensorFlow
Still Python-based, there are such low-level options as tf.matmul and tf.nn.relu, which can be of help when building a neural network architecture and needing to have a tight control over the process.
The layers API will aid one in designing deep neural networks, providing “a first higher level of abstraction over writing things by individual ops.” Aaron exemplifies tf.layers.conv2d that implements a convolutional layer with multiple individual ops.
With the Estimators API, one can define an interface, deliver models to fit into the Estimator system, or tune those models. Then, there are canned estimators—pre-defined models following the estimator conventions (e.g., LinearRegressor
or DNNClassifier
). The functionality available through this collection:
- automatic checkpoints
- automatic logging
- separate training/evaluation/prediction
- simplified training distribution
Well aware of the sophisticated multi-thread, multi-queue, and queue-runner design that TensorFlow offers for loading data, its developers delivered the Dataset API to address this issue and provide a candy interface as a bonus.
Other well-know options to check out include TF-Slim, Keras, and scikit-learn.
APIs outside TensorFlow
Then, there are options cultivated outside the core project by fellow machine learning enthusiasts.
- TFLearn (shouldn’t be confused with TF Learn, which is TensorFlow’s tf.contrib.learn) is a separate Python package.
- TensorLayer comes as a separate package as well and is quite different from what TensorFlow’s layers API has in stall.
- Pretty Tensor is actually a Google’s project, offering fluent interfaces with spoonful of chaining.
- Sonnet, a project of Google’s DeepMind, features a modular approach to that of Torch/NN.
The Jupyter notebook with the supporting files for code demos can be found on Aaron’s GitHub page. For more details, check out his blog post, read Q&As from the webcast on the topic, or view the full webinar recording.
Further reading
- Building Recommenders with Multilayer Perceptron Using TensorFlow
- ML Toolkit for TensorFlow: Out-of-the-Box Algorithms to Boost Training Data by 50x
About the expert
Aaron Schumacher is a data scientist and software engineer for Deep Learning Analytics. He has taught with Python and R for General Assembly and the Metis data science bootcamp. Aaron has also worked with data at Booz Allen Hamilton, New York University, and the New York City Department of Education. You can check out his GitHub repo.