By / Google TensorFlow Team
TensorFlow has evolved into one of the most popular and widely adopted machine learning platforms in the world, and we sincerely thank all the developers and their contributions who have supported us along the way:
-
Researchers: (Predicting earthquake aftershocks, detecting prostate cancer …… )
-
Developers: (Identifying diseased plants, applications to help people lose weight ……)
-
Enterprise Applications: (China Telecom, Zhejiang Mobile, Kingsoft, Shanbay ……, improving customer experience through AI)
-
And many more …
In November 2018, TensorFlow celebrated its 3rd birthday, and we are excited about another important milestone, TensorFlow 2.0!
TensorFlow 2.0 will focus on simplicity and ease of use, featuring the following updates:
-
Easy model building using Keras and eager execution
-
Robust model deployment in production environments on any platform
-
Powerful experimental tools for research
-
Simplified API by cleaning up deprecated APIs and reducing redundancy
Over the past few years, we have added many components to TensorFlow. In TensorFlow 2.0, they will be packaged into a comprehensive platform that supports the machine learning workflow from training to deployment. Let’s understand the new architecture of TensorFlow 2.0 using the simplified conceptual diagram shown below:
Note: Although the training part of the above image focuses on the Python API, TensorFlow.js also supports training models.
Other languages including Swift, R, and Julia are also supported.
Simple Model Building
In a recent article, we announced that the Keras API will become the core high-level API for building and training models in TensorFlow. The Keras API makes it easy to start projects with TensorFlow. Importantly, Keras provides several model-building APIs (Sequential, Functional, and Subclassing), allowing you to choose the appropriate level of abstraction. The implementation of TensorFlow includes several enhancements, including instant iteration and intuitive debugging, as well as tf.data for building scalable input pipelines.
Here is an example workflow (we will update the guide for the content described below in the coming months):
-
Load data using tf.data. Use input pipelines to read training data, using input threads created by tf.data to read training data. Use tf.feature_column to describe features, such as nested and feature crosses. It also supports convenient input from in-memory data (e.g., NumPy)
-
Build, train, and validate models using tf.Keras or Premade Estimators. Keras is tightly integrated with the rest of TensorFlow, so you have access to TensorFlow’s capabilities at any time. A set of standard packaged models (e.g., linear or logistic regression, gradient-boosted trees, random forests) can also be used directly (implemented using the tf.estimator API). If you don’t want to train a model from scratch, you can quickly leverage transfer learning to train Keras or Estimator models using modules from TensorFlow Hub.
-
Run and debug using eager execution, then use tf.function on the graph. TensorFlow 2.0 runs in eager execution mode by default for ease of use and smooth debugging. Additionally, the tf.function annotation transparently converts Python programs into TensorFlow graphs. This process retains all the advantages of graph execution in TensorFlow 1.x: performance optimization, remote execution, and easy serialization, exporting, and deployment capabilities while adding flexibility and ease of use with simple Python expressions.
-
Use distribution strategies for distributed training. For large machine learning training tasks, the Distribution Strategy API makes it easy to distribute and train models on different hardware configurations without changing the model definition. Since TensorFlow provides support for a range of hardware accelerators such as CPU, GPU, and TPU, training workloads can be distributed across single-node/multiple-accelerator and multi-node/multiple-accelerator configurations, including TPU Pods. While this API supports various cluster configurations, it also provides templates for deploying Kubernetes cluster training in local or cloud environments.
-
Export to SavedModel. TensorFlow will standardize on SavedModel as the exchange format for TensorFlow Serving, TensorFlow Lite, TensorFlow.js, TensorFlow Hub, etc.
For detailed information on TensorFlow guides, please refer to:
https://tensorflow.google.cn/guide/?hl=zh-CN
Robust Model Deployment in Production Environments on Any Platform
TensorFlow has always provided a direct path to production. Whether on servers, edge devices, or the web, TensorFlow allows you to easily train and deploy models regardless of the language or platform you use. In TensorFlow 2.0, we improve compatibility and consistency between platforms and components by standardizing exchange formats and adjusting APIs.
Once you have trained and saved a model, you can execute it directly in your application or serve it using one of the following deployment libraries:
-
TensorFlow Serving: The TensorFlow library allows models to be served via HTTP/REST or gRPC/protocol buffers.
-
TensorFlow Lite: TensorFlow provides a lightweight solution for mobile and embedded devices, enabling model deployment on embedded systems like Android, iOS, Raspberry Pi, and Edge TPU.
-
TensorFlow.js: Supports model deployment in JavaScript environments, such as deploying models in web browsers or server-side via Node.js. TensorFlow.js also supports defining models in JavaScript and training directly in web browsers using a Keras-like API.
TensorFlow also supports other languages (some maintained by broader communities), including C, Java, Go, C#, Rust, Julia, R, etc.
Powerful Experimental Tools for Research
TensorFlow makes it easy to turn new ideas from concept to code, from model to release. TensorFlow 2.0 integrates many features that allow you to define and train the latest models without sacrificing speed or performance:
-
Keras Functional API and Model Subclassing API: Allow the creation of complex topologies, including using residual layers, custom multi-input/output models, and forced write-forward passes.
-
Custom training logic: Use tf.GradientTape and tf.custom_gradient for fine-grained control over gradient calculations.
-
For greater flexibility and better control, low-level TensorFlow APIs are always available and combined with high-level abstractions for fully customizable logic.
TensorFlow 2.0 brings new features that allow researchers and advanced users to experiment with rich extensions (such as Ragged Tensors, TensorFlow Probability, Tensor2Tensor, etc.).
In addition to these features, TensorFlow provides eager execution for prototyping and debugging, Distribution Strategy API and AutoGraph for scalable training, and support for TPU, making TensorFlow 2.0 an easy-to-use, customizable, and highly scalable platform for cutting-edge machine learning research and turning research into production pipelines.
Differences Between TensorFlow 1.x and 2.0
Since we first open-sourced TensorFlow, there have been many versions and API iterations. With the rapid development of machine learning, the platform has evolved significantly, now supporting different combinations of users with varying needs. With TensorFlow 2.0, we had the opportunity to clean and modularize the platform based on semantic versioning.
Here are some of the larger changes:
-
Removed queue runners to support tf.data.
-
Removed graph collections.
-
Changed the way variables are handled.
-
Moved and renamed symbols.
Additionally, tf_contrib will be removed from the TensorFlow core repository and build process. The contrib module of TensorFlow has exceeded what a single repository can maintain and support. Larger projects are best maintained separately, while smaller extensions will gradually transition to core TensorFlow code. A special interest group (SIG) has been formed to maintain and further develop some of the more important contrib projects in the future.
If you are interested in contributing, please reply to this thread:
https://github.com/tensorflow/community/pull/37
Compatibility and Continuity
To simplify the transition to TensorFlow 2.0, there will be a conversion tool that can update TensorFlow 1.x Python code to use TensorFlow 2.0 compatible APIs or mark cases where code cannot be automatically converted.
Not all changes can be fully automated. For example, some deprecated APIs have no direct equivalents. This is why we introduced the tensorflow.compat.v1 compatibility module, which retains support for the full TensorFlow 1.x API (excluding tf.contrib). This module will be maintained throughout the lifecycle of TensorFlow 2.x and allows code written with TensorFlow 1.x to continue functioning.
Additionally, SavedModels or stored GraphDefs will be backward compatible. SavedModels saved with 1.x will continue to load and execute in 2.x. However, changes in 2.0 will mean that variable names in original checkpoints may change, so using checkpoints from before 2.0 with code that has been converted to 2.0 may not guarantee normal operation. For more details, please refer to the TensorFlow 2.0 guide:
https://github.com/tensorflow/docs/blob/master/site/en/r2/guide/effective_tf2.md
We believe TensorFlow 2.0 will bring great benefits to application development and we have invested a lot of effort to make the transition as simple as possible. However, we also recognize that transitioning current threads takes time, and we are very concerned about the community’s current investment in learning and using TensorFlow. We will provide 12 months of security patches in the final 1.x release to give existing users ample time to transition and gain all the advantages of TensorFlow 2.0.
TensorFlow 2.0 Timeline
The TensorFlow 2.0 preview will be released early this year.
Why wait? You can already start developing TensorFlow 2.0 by using tf.keras and eager execution, pre-packaged models, and deployment libraries. The Distribution Strategy API is currently partially available.
We are very excited about TensorFlow 2.0 and the upcoming changes. TensorFlow has grown from a software library for deep learning into a complete ecosystem for all types of machine learning. TensorFlow 2.0 will be simple and easy to use for all users on all platforms.
Welcome to join the TensorFlow community, which not only helps you stay updated but also helps everyone use machine learning!
More AI Reading:
-
Achieving Scalability and Flexibility in TensorFlow Architecture
-
tf.data API for Building High-Performance TensorFlow Input Pipelines
-
TensorFlow Helps You Achieve Better Structured Layers and Models