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.Bucketizeop on CPU.tf.whereop for data typestf.int32/tf.uint32/tf.int8/tf.uint8/tf.int64.tf.random.normalop for output data typetf.float32on CPU.tf.random.uniformop for output data typetf.float32on CPU.tf.random.categoricalop for output data typetf.int64on 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.
-
ConversionParamsAPI which is a part of theTrtGraphConverterV2and is used to set the parameters for TF-TRT conversion is now deprecated and it's arguments can be specified directly now. These arguments aremax_workspace_size_bytes,precision_mode,minimum_segment_size,maximum_cached_engines,use_calibrationandallow_build_at_runtime. -
A new parameter called
save_gpu_specific_enginesis now added to the.save()function insideTrtGraphConverterV2. When set toFalse, this function won't save any TRT engines that were built. Setting toTruepreserves the original behavior. -
A new API called
.summary()is added toTrtGraphConverterV2which displays a summary of the inference converted by TF-TRT. It basically lists out all theTRTEngineOpwith their input and output shape. Basically aTRTEngineOpis the building block of aTensorRTengine.
(tf.tpu.experimental.embedding):
-
Now an additional argument
output_shapehas been added totf.tpu.experimental.embedding.FeatureConfigwhich 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.TPUEmbeddingbehaves in the same way astf.tpu.experimental.embedding.serving_embedding_lookup.serving_embedding_lookup()typically applies standard lookup ops with the specifiedtf.tpu.experimental.embeddingconfigs
tf.config.experimental.enable_op_determinism:
TF_DETERMINISTIC_OPSenvironmental variable is now deprecated and is replaced bytf.config.experimental.enable_op_determinismwhich 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_batchoptimization is now the default method. This has to be disabled by the user if not needed.TensorSliceDatasetcan 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::SetNumThreadshas been deprecated and insteadInterpreterBuilder::SetNumThreadsshould be used when setting the number of threads.
-
tf.keras:tf.compat.v1.keras.utils.get_or_create_layeris added that tracks nested Keras models created in TF1 style and helps migrating to TF2. It has to be used with thetf.compat.v1.keras.utils.track_tf1_style_variablesdecorator.tf.keras.layers.experimental.preprocessing.HashedCrossinglayer 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.CategoryCrossinghas been dropped, and instead a HashedCrossing layer ortf.sparse.cross/tf.ragged.crossmethod has to be used.
TextVectorizationnow has two additional modes calledstandardizeandsplitmodes:- 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.SidecarEvaluatoris deprecated andtf.keras.utils.SidecarEvaluatorwill be used in it's place.tf.keras.callbacks.experimental.BackupAndRestoreis also deprecated andtf.keras.callbacks.BackupAndRestorewill 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.Generatorclass 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_ndand other scatter functions, like thetf.tensor_scatter_nd_updatecan 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_determinismis called and when these operations are made to follow the specified path on a GPU will trigger thetf.errors.UnimplementedErrorto 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:FakeQuantWithMinMaxVarsGradientandFakeQuantWithMinMaxVarsPerChannelGradienttf.nn.depthwise_conv2dtf.nn.dilation2dandtf.nn.max_pool_with_argmaxgradientstf.raw_ops.DebugNumericSummaryandtf.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'sIsSimplifiableReshape,SafeToRemoveIdentity,TensorByteSize& in binary ops due to type confusion. - Fixed a null pointer dereference in
BuildXlaCompilationCache& Grappler'sIsConstant - Fixed an integer overflows in most sparse component-wise ops (eg:
SparseCountSparseOutput),AddManySparseToTensorsMap, TFLite array creation, TFLite, shape inference forDequantize,OpLevelCostEstimator::CalculateTensorSize&OpLevelCostEstimator::CalculateOutputSize. - Fixed a heap OOB access in
Dequantize,FractionalAvgPoolGrad& inRunForwardTypeInference. - 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.