Overview
TensorFlow 2.6, released on August 12, 2021, separates Keras as an independent module and improves integration with the TensorFlow ecosystem.
Main Features
Keras as separate module
Keras is now distributed as a standalone package (keras) while remaining accessible via tf.keras. This separation enables independent release cycles and better modularity.
python
import tensorflow as tf
# Keras remains accessible via tf.keras
model = tf.keras.Sequential([
tf.keras.layers.Dense(128, activation='relu', input_shape=(784,)),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax'),
])
model.compile(
optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'],
)
model.summary()
Ecosystem improvements
TensorFlow 2.6 improves model serialization support, Python 3.9 compatibility, and eager execution mode performance.
python
import tensorflow as tf
# Improved save and load
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(1),
])
model.build(input_shape=(None, 10))
# SavedModel with signatures
# tf.saved_model.save(model, './my_model')
# Improved eager mode
x = tf.random.normal((32, 10))
y = model(x) # immediate execution
print(f'Output: {y.shape}') # (32, 1)
