TensorFlow 1.x vs 2.x. – changes
TensorFlow 1.0 vs TensorFlow 2.0
Tensorflow 2.0 does not feel new. Probably because even in the age of Tensorflow 1.0, almost everyone was using keras!. Keras is now central to Tensorflow 2.0 but Tensorflow 2.0 has much more features.
Ease of use:TensorFlow 2.0 promotes TensorFlow Keras for model experimentation and Estimators for scaled serving, and the two APIs are very convenient to use.
Eager Execution: TensorFlow2.0 Eager Execution is implemented by default, i.e. you no longer need to create a session.
Model Building and deploying made easy:TensorFlow 2.0 provides the user to create a callable graph using a python function @tf.function. The tf.function() will create a separate graph for every unique set of input shapes and datatypes.
The Data pipeline simplified:TensorFlow 2.0 you can build your model defining your own mathematical operations.you can take advantage of the high level Keras API and tf.layers module. The important part is we do not need to define placeholders any more.
Some important points are:
- Load your data using data. Training data is read using input pipelines which are created using tf.data.
- Use TensorFlow Dataset to get a large variety of datasets to train your model.
- Build, train and validate your model with keras, or use Estimators API.
- TensorFlow Hub in the TensorFlow ecosysytem contains a large number of pretrained models, using the standard interface, you can import any of the models from TensorFlow Hub and either train it from scratch or fine tune it for your data using transfer learning technique.
- Run and debug with eager execution, then use functionfor the benefits of graphs.
- Use Distribution Strategies for distributed training. For large ML training tasks, the Distribution Strategy APImakes it easy to distribute and train models on different hardware configurations without changing the model definition. You can distribute your training load to a range of hardware accelerators like CPUs, GPUs, and TPUs
- Although this API supports a variety of cluster configurations, templatesto deploy training on Kubernetes clusters in on-prem or cloud environments are provided.
- Export to SavedModel. TensorFlow will standardize on SavedModel as an interchange format for TensorFlow Serving, TensorFlow Lite, TensorFlow.js, TensorFlow Hub, and more.
- Once you’ve trained and saved your model, you can execute it directly in your application or serve it using one of the deployment libraries: TensorFlow Serving: A TensorFlow library allowing models to be served over HTTP/REST or gRPC/Protocol Buffers. TensorFlow Lite: TensorFlow’s lightweight solution for mobile and embedded devices provides the capability to deploy models on Android, iOS and embedded systems like a Raspberry Pi and Edge TPUs. js: Enables deploying models in JavaScript environments, such as in a web browser or server side through Node.js. TensorFlow.js also supports defining models in JavaScript and training directly in the web browser using a Keras-like API.