×

Search anything:

New features in TensorFlow v2.8

Binary Tree book by OpenGenus

Open-Source Internship opportunity by OpenGenus for programmers. Apply now.

TensorFlow version 2.8 is the latest official release of TensorFlow. Let us take a look at some of the new features and improvements being rolled out in this version. TensorFlow is one of the most popular framework for writing Deep Learning and Machine Learning models. This new version comes with lots of additions, bug fixes and changes.

What's new?

Let us take a module-wise look at some of the additions and improvements

TensorFlow Lite (tf.lite):

TensorFlow Lite is the framework created specifically for Mobile Devices and IoT. The latest 2.80 release version adds some of the existing TensorFlow operations from the main framework to the mobile version. These are:

  • tf.raw_ops.Bucketize op on CPU.
  • tf.where op for data types tf.int32/tf.uint32/tf.int8/tf.uint8/tf.int64.
  • tf.random.normal op for output data type tf.float32 on CPU.
  • tf.random.uniform op for output data type tf.float32 on CPU.
  • tf.random.categorical op for output data type tf.int64 on CPU.

TensorRT (TF-TRT) (tf.experimental.tensorrt):

TensorRT provides high performance inference on NVIDIA GPUs and accelerators for deep learning. It is available as a standalone C++ library. TF-TRT is an integration of the TensorRT into the TensorFlow library. The standalone module is being developed actively, it is added as an experimental feature to TensorFlow.

  • ConversionParams API which is a part of the TrtGraphConverterV2 and is used to set the parameters for TF-TRT conversion is now deprecated and it's arguments can be specified directly now. These arguments are max_workspace_size_bytes, precision_mode, minimum_segment_size, maximum_cached_engines, use_calibration and allow_build_at_runtime.

  • A new parameter called save_gpu_specific_engines is now added to the .save() function inside TrtGraphConverterV2. When set to False, this function won't save any TRT engines that were built. Setting to True preserves the original behavior.

  • A new API called .summary() is added to TrtGraphConverterV2 which displays a summary of the inference converted by TF-TRT. It basically lists out all the TRTEngineOp with their input and output shape. Basically a TRTEngineOp is the building block of a TensorRT engine.

(tf.tpu.experimental.embedding):

  • Now an additional argument output_shape has been added to tf.tpu.experimental.embedding.FeatureConfig which can specify the shape of the output activation for the feature. This stores the configuration data for one embedding feature.

  • Now, tf.tpu.experimental.embedding.TPUEmbedding behaves in the same way as tf.tpu.experimental.embedding.serving_embedding_lookup. serving_embedding_lookup() typically applies standard lookup ops with the specified tf.tpu.experimental.embedding configs

tf.config.experimental.enable_op_determinism:

  • TF_DETERMINISTIC_OPS environmental variable is now deprecated and is replaced by tf.config.experimental.enable_op_determinism which when set will run the ops in a deterministic way and thus would use more resources and have an impact on the performance.

Bug fixes and changes:

  • TensorFlow has been validated for use on WSL 2 (Windows Subsystem for Linux 2) for both GPUs and CPUs.

  • Boosted tree codes will soon be completely removed due to security reasons, and users should switch to TensorFlow's Decision Trees.

  • tf.data:

    • parallel_batch optimization is now the default method. This has to be disabled by the user if not needed.
    • TensorSliceDataset can now identify when file is given as an input. This will allow to create hermetic SavedModels.
  • tf.lite:

    • GPU Delegation support is added to allow serialization to JAVA API. This boosts up the initialization time when working with OpenCL.
    • Interpreter::SetNumThreads has been deprecated and instead InterpreterBuilder::SetNumThreads should be used when setting the number of threads.
  • tf.keras:

    • tf.compat.v1.keras.utils.get_or_create_layer is added that tracks nested Keras models created in TF1 style and helps migrating to TF2. It has to be used with the tf.compat.v1.keras.utils.track_tf1_style_variables decorator.
    • tf.keras.layers.experimental.preprocessing.HashedCrossing layer is newly added which will apply the hashing trick to the crossed scalar inputs (between an integer and a string). It provides a stateless way of adding feature crosses to a model.
      • keras.layers.experimental.preprocessing.CategoryCrossing has been dropped, and instead a HashedCrossing layer or tf.sparse.cross/tf.ragged.cross method has to be used.
    • TextVectorization now has two additional modes called standardize and split modes:
      • standardize="lower" will convert the input to lowercase.
      • standardize="string_punctuation" will remove all puncuation from the input.
      • split="character" will split whenver a unicode character is encountered.
    • Two of the experimental features have been converted to mainstream features:
      • tf.keras.experimental.SidecarEvaluator is deprecated and tf.keras.utils.SidecarEvaluator will be used in it's place.
      • tf.keras.callbacks.experimental.BackupAndRestore is also deprecated and tf.keras.callbacks.BackupAndRestore will be used in it's place.
    • 3 new APIs have been added in the keras backend to enable, disable or check the usage of the tf.random.Generator class that is responsible. These APIs allows user to disable and revert back to legacy code.
  • Deterministic Op Functionality:

    • Regression in deterministic selection of deterministic cuDNN convolution algorithms has been fixed.
    • tf.scatter_nd and other scatter functions, like the tf.tensor_scatter_nd_update can be made to run on CPU but has significant performance hit.
    • Deterministic GPU implementations of various of various APIs has been added.
    • Now an exception will be thrown when determinism isn't successfully implemented for certain operations. That is when tf.config.experimental.enable_op_determinism is called and when these operations are made to follow the specified path on a GPU will trigger the tf.errors.UnimplementedError to show up. Users can explicitly turn this off, if they don't want to see it but it's default behaviour is to show up. Some of these important operations are:
      • FakeQuantWithMinMaxVarsGradient and FakeQuantWithMinMaxVarsPerChannelGradient
      • tf.nn.depthwise_conv2d
      • tf.nn.dilation2d and tf.nn.max_pool_with_argmax gradients
      • tf.raw_ops.DebugNumericSummary and tf.raw_ops.DebugNumericSummaryV2

These are some of the operations, for a complete list please refer to the changelog available on the official TensorFlow repository.

Security fixes:

The next set of improvements are all about security fixes. Most of which are fixing integer overflows or heap OOB read/write memory access to functions of various namespaces in the Public API and fixing various other vulnerablities. These changes are listed out on the release page. Some of the important security fixes are:

  • Fixed a floating point division by 0 when convolution operators are executed.
  • Fixed a division by zero in FractionalMaxPool
  • Fixed multiple CHECK-failures during Grappler's IsSimplifiableReshape, SafeToRemoveIdentity, TensorByteSize & in binary ops due to type confusion.
  • Fixed a null pointer dereference in BuildXlaCompilationCache & Grappler's IsConstant
  • Fixed an integer overflows in most sparse component-wise ops (eg: SparseCountSparseOutput), AddManySparseToTensorsMap, TFLite array creation, TFLite, shape inference for Dequantize, OpLevelCostEstimator::CalculateTensorSize & OpLevelCostEstimator::CalculateOutputSize.
  • Fixed a heap OOB access in Dequantize, FractionalAvgPoolGrad & in RunForwardTypeInference.
  • Fixed a dangerous OOB write in TFLite
  • Fixed a heap OOB read/write in SpecializeType

With this article at OpenGenus, you must have a strong idea of the New features in TensorFlow v2.8.

New features in TensorFlow v2.8
Share this