Overview
TensorFlow 2.14, released on September 8, 2023, requires NumPy 1.24+ and improves tf.function performance.
Main Features
NumPy 1.24+ required
Compatibility with NumPy 1.24+ enables new types and improves array interoperability.
python
import tensorflow as tf
import numpy as np
# Seamless NumPy <-> TensorFlow conversion
arr = np.array([1.0, 2.0, 3.0], dtype=np.float32)
tensor = tf.constant(arr)
result = tf.math.reduce_sum(tensor)
print(result.numpy()) # 6.0
Improved tf.function
tf.function tracing is faster and uses less memory during graph compilation.
python
import tensorflow as tf
@tf.function(reduce_retracing=True)
def train_step(x, y):
with tf.GradientTape() as tape:
pred = model(x, training=True)
loss = loss_fn(y, pred)
grads = tape.gradient(loss, model.trainable_variables)
optimizer.apply_gradients(zip(grads, model.trainable_variables))
return loss
