TensorFlow API Documentation | The Use of the TensorFlow API
Let's take a look at the TensorFlow API documentation as well as explore what the TensorFlow APIs are and how they work.
Join the DZone community and get the full member experience.Join For Free
What Is TensorFlow API?
TensorFlow is similar to a python package and a lot of features are similar to that of Python, but the main core of TensorFlow is a distributed runtime. This functionality is implemented in many languages and one of them is Python.
TensorFlow API: TensorFlow Runtime Engine
This is the diagram of TensorFlow’s distributed Execution engine or the runtime engine. The other way to visualize the above diagram is to think of it as a virtual machine whose language is TensorFlow. The runtime of TensorFlow is written in the C++ language, but the front-end, as you can see, can be implemented by using various languages like C, C++, R, Java, etc. The use of these API’s in TensorFlow is explained below.
C API for TensorFlow
The only APIs having the official backing of TensorFlow are C and Python API (some parts). C APIs should be used whenever you are about to make a TensorFlow API for some other languages, as lots of languages have ways to connect with C language.
C++ API for TensorFlow
The runtime of TensorFlow is written in C++, and mostly, C++ is connected to TensorFlow through header files in tensorflow/cc. The C++ API still is in experimental stages of development, but Google commits to working with C++.
Python API for TensorFlow
Python is the most recognizable and the "main” language when it comes to TensorFlow and its development. It was one of the first languages supported by TensorFlow and still supports most of the features. It seems as though TensorFlow’s functionality defines in Python and then moves to C++.
The Python API is so diverse in nature that you will have to choose what level of API in TensorFlow you want to work on.
R API for TensorFlow
The R API for TensorFlow made by RStudio has some different approach than the traditional approach for providing API support. R API fully contains the Python API which is different from what TensorFlow goes with its APIs. But the users of R have all the access to features of Python API.
Further, one can see there are other APIs available for Java, Go, Rust, Haskel, and some of the other unofficial ones outside of TensorFlow project — C# and Julia.
APIs Inside TensorFlow Project
The API’s inside TensorFlow are still Python-based, and they have low-level options for its users such as tf.manual or tf.nnrelu, which are used to build neural network architecture. These APIs also use to aid in designing a deep neural network having higher levels of abstraction.
Using the Estimators API, you can define an interface and can deliver models to fit into the Estimator system. Canned estimators — pre-defined models — are present there, which follows the estimator conventions for e.g., LinearRegressor or DNNClassifier. The functionality available through this collection are as follows:
- automatic checkpoints
- automatic logging
- separate training/evaluation/prediction
- simplified training distribution
API in TensorFlow: API Inside TensorFlow Project
TensorFlow is offering sophisticated multi-thread, multi-queue, and queue-runner design that are used for loading data. The developers of TensorFlow delivered the Dataset API to address this issue and provide a candy interface as a bonus. The following diagram is from Google/IO, which has added XLA.
API Inside TensorFlow Project
Other known options to consider for API’s are TF-Slim, Keras, and scikit-learn.
APIs Outside TensorFlow Project
Some other TensorFlow API’s which develop outside of the TensorFlow project by Machine Learning enthusiasts. Let’s see some TensorFlow API outside TensorFlow Project:
- TFLearn: This API shouldn’t be seen as TF Learn, which is TensorFlow’s tf.contrib.learn. It is a separate Python package.
- TensorLayer: It comes as a separate package and is different from what TensorFlow’s layers API has in its bag.
- Pretty Tensor: It is actually a Google project that offers a fluent interface with chaining.
- Sonnet: It is a project of Google’s DeepMind that features a modular approach.
So, this was all about the TensorFlow API Documentation. I hope you liked our explanation.
In this article, we saw what the TensorFlow APIs are and how they work. Moreover, we got to know about the TensorFlow API for different languages. In addition, we also studied how TensorFlow is different from Python and how it got its own identity in Machine Learning and Deep Neural Network areas. At last, we discussed APIs inside and outside of the TensorFlow Project. Next, we will work with MNIST in TensorFlow. Furthermore, if you have any questions, feel free to ask in the comments section. Thank you!
Published at DZone with permission of Rinu Gour. See the original article here.
Opinions expressed by DZone contributors are their own.