TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of toolslibraries, and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML-powered applications.

Release 2.2.0

TensorFlow 2.2 discontinues support for Python 2, previously announced as following Python 2’s EOL on January 1, 2020.

Coinciding with this change, new releases of TensorFlow’s Docker images provide Python 3 exclusively. Because all images now use Python 3, Docker tags containing -py3 will no longer be provided and existing -py3 tags like latest-py3 will not be updated.

Deep Learning Workstations & Servers

Major Features and Improvements

  • Replaced the scalar type for string tensors from std::string to tensorflow::tstring which is now ABI stable.
  • A new Profiler for TF 2 for CPU/GPU/TPU. It offers both device and host performance analysis, including input pipeline and TF Ops. Optimization advisory is provided whenever possible. Please see this tutorial and guide for usage guidelines.
  • Export C++ functions to Python using pybind11 as opposed to SWIG as a part of our deprecation of swig efforts.
  • tf.distribute:
    • Support added for global sync BatchNormalization by using the newly added tf.keras.layers.experimental.SyncBatchNormalization layer. This layer will sync BatchNormalization statistics every step across all replicas taking part in sync training.
    • Performance improvements for GPU multi-worker distributed training using tf.distribute.experimental.MultiWorkerMirroredStrategy
      • Update NVIDIA NCCL to 2.5.7-1 for better performance and performance tuning. Please see nccl developer guide for more information on this.
      • Support gradient allreduce in float16. See this example usage.
      • Experimental support of all reduce gradient packing to allow overlapping gradient aggregation with backward path computation.
      • Deprecated experimental_run_v2 method for distribution strategies and renamed the method run as it is no longer experimental.
      • Add CompositeTensor support for DistributedIterators. This should help prevent unnecessary function retracing and memory leaks.
  • tf.keras:
    • Model.fit major improvements:
      • You can now use custom training logic with Model.fit by overriding Model.train_step.
      • Easily write state-of-the-art training loops without worrying about all of the features Model.fit handles for you (distribution strategies, callbacks, data formats, looping logic, etc)
      • See the default Model.train_step for an example of what this function should look like. Same applies for validation and inference via Model.test_step and Model.predict_step.
      • SavedModel uses its own Model._saved_model_inputs_spec attr now instead of
        relying on Model.inputs and Model.input_names, which are no longer set for subclass Models.
        This attr is set in eager, tf.function, and graph modes. This gets rid of the need for users to
        manually call Model._set_inputs when using Custom Training Loops(CTLs).
      • Dynamic shapes are supported for generators by calling the Model on the first batch we “peek” from the generator.
        This used to happen implicitly in Model._standardize_user_data. Long-term, a solution where the
        DataAdapter doesn’t need to call the Model is probably preferable.
    • The SavedModel format now supports all Keras built-in layers (including metrics, preprocessing layers, and stateful RNN layers)
    • Update Keras batch normalization layer to use the running mean and average computation in the fused_batch_norm. You should see significant performance improvements when using fused_batch_norm in Eager mode.
  • tf.lite:
    • Enable TFLite experimental new converter by default.
  • XLA
    • XLA now builds and works on windows. All prebuilt packages come with XLA available.
    • XLA can be enabled for a tf.function with “compile or throw exception” semantics on CPU and GPU.

Breaking Changes

  • tf.keras:
    • In tf.keras.applications the name of the “top” layer has been standardized to “predictions”. This is only a problem if your code relies on the exact name of the layer.
    • Huber loss function has been updated to be consistent with other Keras losses. It now computes mean over the last axis of per-sample losses before applying the reduction function.
  • AutoGraph no longer converts functions passed to tf.py_function, tf.py_func and tf.numpy_function.
  • Deprecating XLA_CPU and XLA_GPU devices with this release.
  • Increasing the minimum bazel version to build TF to 2.0.0 to use Bazel’s cc_experimental_shared_library.
  • Keras compile/fit behavior for functional and subclassed models have been unified. Model properties such as metrics, metrics_names will now be available only after training/evaluating the model on actual data for functional models. metrics will now include model loss and output losses.loss_functions property has been removed from the model. This was an undocumented property that was accidentally public and has now been removed.

Known Caveats

  • The current TensorFlow release now requires gast version 0.3.3.

Bug Fixes and Other Changes

  • tf.data:
    • Removed autotune_algorithm from experimental optimization options.
  • TF Core:
    • tf.constant always creates CPU tensors irrespective of the current device context.
    • Eager TensorHandles maintain a list of mirrors for any copies to local or remote devices. This avoids any redundant copies due to op execution.
    • For tf.Tensor & tf.Variable, .experimental_ref() is no longer experimental and is available as simply .ref().
    • pfor/vectorized_map: Added support for vectorizing 56 more ops. Vectorizing tf.cond is also supported now.
    • Set as much partial shape as we can infer statically within the gradient impl of the gather op.
    • Gradient of tf.while_loop emits StatelessWhile op if cond and body functions are stateless. This allows multiple gradients while ops to run in parallel under distribution strategy.
    • Speed up GradientTape in eager mode by auto-generating list of op inputs/outputs which are unused and hence not cached for gradient functions.
    • Support back_prop=False in while_v2 but mark it as deprecated.
    • Improve error message when attempting to use None in data-dependent control flow.
    • Add RaggedTensor.numpy().
    • Update RaggedTensor.__getitem__ to preserve uniform dimensions & allow indexing into uniform dimensions.
    • Update tf.expand_dims to always insert the new dimension as a non-ragged dimension.
    • Update tf.embedding_lookup to use partition_strategy and max_norm when ids is ragged.
    • Allow batch_dims==rank(indices) in tf.gather.
    • Add support for bfloat16 in tf.print.
  • tf.distribute:
    • Support embedding_column with variable-length input features for MultiWorkerMirroredStrategy.
  • tf.keras:
    • Added experimental_aggregate_gradients argument to tf.keras.optimizer.Optimizer.apply_gradients. This allows custom gradient aggregation and processing aggregated gradients in custom training loop.
    • Allow pathlib.Path paths for loading models via Keras API.
  • tf.function/AutoGraph:
    • AutoGraph is now available in ReplicaContext.merge_call, Strategy.extended.update and Strategy.extended.update_non_slot.
    • Experimental support for shape invariants has been enabled in tf.function. See the API docs for tf.autograph.experimental.set_loop_options for additonal info.
    • AutoGraph error messages now exclude frames corresponding to APIs internal to AutoGraph.
    • Improve shape inference for tf.function input arguments to unlock more Grappler optimizations in TensorFlow 2.x.
    • Improve automatic control dependency management of resources by allowing resource reads to occur in parallel and synchronizing only on writes.
    • Fix execution order of multiple stateful calls to experimental_run_v2 in tf.function.
    • You can now iterate over RaggedTensors using a for loop inside tf.function.
  • tf.lite:
    • Migrated the tf.lite C inference API out of experimental into lite/c.
    • Add an option to disallow NNAPI CPU / partial acceleration on Android 10
    • TFLite Android AARs now include the C headers and APIs are required to use TFLite from native code.
    • Refactors the delegate and delegate kernel sources to allow usage in the linter.
    • Limit delegated ops to actually supported ones if a device name is specified or NNAPI CPU Fallback is disabled.
    • TFLite now supports tf.math.reciprocal1 op by lowering to tf.div op.
    • TFLite’s unpack op now supports boolean tensor inputs.
    • Microcontroller and embedded code moved from experimental to main TensorFlow Lite folder
    • Check for large TFLite tensors.
    • Fix GPU delegate crash with C++17.
    • Add 5D support to TFLite strided_slice.
    • Fix error in delegation of DEPTH_TO_SPACE to NNAPI causing op not to be accelerated.
    • Fix segmentation fault when running a model with LSTM nodes using NNAPI Delegate
    • Fix NNAPI delegate failure when an operand for Maximum/Minimum operation is a scalar.
    • Fix NNAPI delegate failure when Axis input for reduce operation is a scalar.
    • Expose option to limit the number of partitions that will be delegated to NNAPI.
    • If a target accelerator is specified, use its feature level to determine operations to delegate instead of SDK version.
  • tf.random:
    • Various random number generation improvements:
      • Add a fast path for default random_uniform
      • random_seed documentation improvement.
      • RandomBinomial broadcasts and appends the sample shape to the left rather than the right.
    • Added tf.random.stateless_binomial, tf.random.stateless_gamma, tf.random.stateless_poisson
    • tf.random.stateless_uniform now supports unbounded sampling of int types.
  • Math and Linear Algebra:
    • Add tf.linalg.LinearOperatorTridiag.
    • Add LinearOperatorBlockLowerTriangular
    • Add broadcasting support to tf.linalg.triangular_solve#26204, tf.math.invert_permutation.
    • Add tf.math.sobol_sample op.
    • Add tf.math.xlog1py.
    • Add tf.math.special.{dawsn,expi,fresnel_cos,fresnel_sin,spence}.
    • Add a Modified Discrete Cosine Transform (MDCT) and its inverse to tf.signal.
  • TPU Enhancements:
    • Refactor TpuClusterResolver to move shared logic to a separate pip package.
    • Support configuring TPU software version from cloud tpu client.
    • Allowed TPU embedding weight decay factor to be multiplied by learning rate.
  • XLA Support:
    • Add standalone XLA AOT runtime target + relevant .cc sources to pip package.
    • Add check for memory alignment to MemoryAllocation::MemoryAllocation() on 32-bit ARM. This ensures a deterministic early exit instead of a hard to debug bus error later.
    • saved_model_cli aot_compile_cpu allows you to compile saved models to XLA header+object files and include them in your C++ programs.
    • Enable Igamma, Igammac for XLA.
  • Deterministic Op Functionality:
    • XLA reduction emitter is deterministic when the environment variable TF_DETERMINISTIC_OPS is set to “true” or “1”. This extends deterministic tf.nn.bias_add back-prop functionality (and therefore also deterministic back-prop of bias-addition in Keras layers) to include when XLA JIT complilation is enabled.
    • Fix problem, when running on a CUDA GPU and when either environment variable TF_DETERMINSTIC_OPS or environment variable TF_CUDNN_DETERMINISTIC is set to “true” or “1”, in which some layer configurations led to an exception with the message “No algorithm worked!”
  • Tracing and Debugging:
    • Add source, destination name to _send traceme to allow easier debugging.
    • Add traceme event to fastpathexecute.
  • Other:
    • Fix an issue with AUC.reset_states for multi-label AUC #35852
    • Fix the TF upgrade script to not delete files when there is a parsing error and the output mode is in-place.
    • Move tensorflow/core:framework/*_pyclif rules to tensorflow/core/framework:*_pyclif.

This release has 2 assets:

  • Source code (zip)
  • Source code (tar.gz)

Visit the release page to download them.

About TensorFlow

Whether you’re an expert or a beginner, TensorFlow is an end-to-end platform that makes it easy for you to build and deploy machine learning (ML) models.

TensorFlow was originally developed by researchers and engineers working on the Google Brain team within Google’s Machine Intelligence Research organization to conduct machine learning and deep neural networks research. The system is general enough to be applicable in a wide variety of other domains, as well.

TensorFlow provides stable Python and C++ APIs, as well as non-guaranteed backward compatible API for other languages.

Easy model building

TensorFlow offers multiple levels of abstraction so you can choose the right one for your needs. Build and train models by using the high-level Keras API, which makes getting started with TensorFlow and machine learning easy.

If you need more flexibility, eager execution allows for immediate iteration and intuitive debugging. For large ML training tasks, use the Distribution Strategy API for distributed training on different hardware configurations without changing the model definition.

Robust ML production anywhere

TensorFlow has always provided a direct path to production. Whether it’s on servers, edge devices, or the web, TensorFlow lets you train and deploy your model easily, no matter what language or platform you use.

Use TensorFlow Extended (TFX) if you need a full production ML pipeline. For running inference on mobile and edge devices, use TensorFlow Lite. Train and deploy models in JavaScript environments using TensorFlow.js.

Powerful experimentation for research

Build and train state-of-the-art models without sacrificing speed or performance. TensorFlow gives you the flexibility and control with features like the Keras Functional API and Model Subclassing API for creation of complex topologies. For easy prototyping and fast debugging, use eager execution.

TensorFlow also supports an ecosystem of powerful add-on libraries and models to experiment with, including Ragged Tensors, TensorFlow Probability, Tensor2Tensor and BERT.

Click here to install TensorFlow 2.


Contact Exxact