TensorFlow splits off Keras, hits 2.6 with lots of security fixes

TensorFlow splits off Keras, hits 2.6 with lots of security fixes

Deep learning framework TensorFlow 2.6 has left the beta testing phase behind, and is now ready for general consumption. Machine learning types have to be careful though, since the release comes with a few breaking changes that need to be considered when making the switch.

Amongst other things, version 2.6 finally makes good on the promise to get the TensorFlow implementation of Keras its own repository. Initially the project wasn’t part of the Google-backed TensorFlow organisation at all but an independent library that could be used with a CNTK and Theano backend as well as TF. Over time, the TensorFlow implementation however superseded the original thanks to additional features such as TPU training, eager execution, and distribution. The Keras team therefore decided to discontinue multi-backend Keras and concentrate efforts on tf.keras instead. 

When Keras 2.4 was released in June 2020, Keras creator Francois Chollet mentioned that development under the TensorFlow banner might only be a temporary option, pointing to keras-team/keras as a potential future home. With TensorFlow 2.6 this split has been realised and Keras has become its own separate PIP package again. API endpoints are said to stay as they are, with the exception that they are now backed by the keras PIP package. Users who import tensorflow.python.keras need to figure out how to use the public tf.keras API though.

The Keras team wouldn’t be the Keras team if it didn’t have more changes up its sleeve and so it for example replaced methods Model.to_yaml() and keras.models.model_from_yaml to raise a RuntimeError “as they can be abused to cause arbitrary code execution”. Better alternatives include JSON or H5 serialisation. Keras 2.6 also includes stabilised preprocessing layers and associated APIs, as well as an experimental sidecar evaluator for programs meant to be run on evaluator tasks or single-worker training.

Looking into the TensorFlow core, there are a couple of new experimental additions such as a generic mutable hash table implementation, or tf.config.experimental.reset_memory_stats for resetting the tracked peak memory which can be accessed via tf.config.experimental.get_memory_info. Version 2.6 also allows the creation of custom wrapper objects for resource tensors and provides a SavedModel load option as well as a SparseSegmentSumGrad operator to speed up this gradient calculation.

Developers who have had trouble using tf.while_loop for parallel execution will be happy to hear that the relevant bug has been fixed. However, the change might cause TensorFlow to occupy more memory, so users should keep an eye on their setup’s behaviour and reset their while_loop’s parallel_iterations value to 1, should the situation get out of hand.
A full list of changes, including a whole array of newly stabilised data APIs and a long list of security fixes, can be found in the TensorFlow release notes.