pypi / tensorflow
tensorflow
What changed in tensorflow 1 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
77 breaking2 security20 deprecations68 new APIs and options2 performance17 behavior and defaults1 tooling4 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli inittensorflow 2125 changes
Breaking changes 41
Support for Python 3.9 has been removed, so developers must use a supported Python version.
The TensorBoard dependency has been removed from TensorFlow.
Removed as a public API; use GradientTape to compute gradients.
Call build() to optimize TensorRT engines during graph optimization, replacing the prior is_dynamic_op=False approach.
Removed; provide calibration_input_fn to converter.convert() to trigger calibration.
No longer returns a tf.function; access the function from the saved model.
The negate sign is removed from cosine similarity in the loss.
DType is no longer convertible to an int; use dtype.as_datatype_enum to get the same result.
Renamed to export_saved_model.
Set experimental_run_tf_function=False in compile to unblock use cases affected by the unified Keras execution path.
The command-line tool was removed; use SavedModel instead of frozen graphs.
The default for gradient accumulation for TPU embeddings is now true.
Use GradientTape to compute gradients in place of the removed public compute_gradients API.
Now supports gradients for new resize kernels and uses proper pixel centers, with new kernels including anti-aliasing.
Canned Estimators no longer support this argument; use compat.v1 canned Estimators if needed.
The default Keras configuration no longer uses this environment variable to configure thread count; use tf.config.threading APIs.
ResourceVariable no longer accepts constraint in its constructor or exposes .constraint.
Tensors are no longer hashable and compare element-wise with == and !=; compat.v1.disable_tensor_equality restores the previous behavior.
Use this environment variable in place of the deprecated CUDA-related install path variables; it accepts comma-separated base paths.
Restore the previous Tensor equality behavior using this compatibility API.
Use the v1 estimator family to avoid the optimizer behavior change in the premade estimators.
Removed from tf.data.Options.
The default aggregation for canned Estimators is now SUM_OVER_BATCH_SIZE; pass SUM to retain the previous default behavior.
Premade estimators use Keras optimizers by default when optimizer is omitted or specified as a string; optimizer variables differ, making this checkpoint breaking.
Use shared_embeddings instead of shared_embedding_columns when working with v1 and v2 feature columns.
Global-variable helper methods are no longer needed in TensorFlow 2.0.
Set the default dtype to float64 with set_floatx if a model should not use the new float32 layer default.
Raises an error if batch_size is supplied when the input is a dataset, generator, or Keras sequence.
The default recurrent activation changed from hard_sigmoid to sigmoid; reset_after also defaults to True, enabling the unified CPU/GPU implementation and CuDNN compatibility.
Layers now default to float32 and automatically cast inputs to the layer dtype.
The norm_axis and params_axis arguments were replaced by axis.
Standardized the API by replacing norm_axis and params_axis with axis.
Losses are scaled in Keras compile/fit rather than in optimizers; custom training loops can use the new loss-scaling utilities.
Keras fit uses a unified execution path by default, converting inputs to Dataset and wrapping the training step in tf.function unless run_eagerly=True; some use cases retain fallback paths.
Saving now defaults to TensorFlow SavedModel format; HDF5 remains supported.
Training APIs raise ValueError if an integer is passed.
Use Keras optimizers in TensorFlow 2.0; canned Estimators also use them by default, which can make checkpoints incompatible with earlier optimizer variables.
For num greater than 1, the final value is now always stop.
Removed from the TensorFlow 2.0 Lite API.
Removed from the v2 API.
Added a TensorFlow 2.0-compatible API for TensorRT conversion using TrtConversionParams.
Security 2
Fixed an out-of-bounds access in the color palette when processing malformed GIF images.
Fixed a potential heap out-of-bounds vulnerability when decoding variant tensors from proto.
Deprecations 11
The TensorFlow 1.x API remains available through the compat.v1 module.
Deprecated; use TF_CUDA_PATHS instead.
SignatureDef utility functions are deprecated.
Deprecated; functionality has moved to core TensorFlow, ecosystem projects, or been removed.
Deprecated in favor of tf.keras.layers.DenseFeatures.
Deprecated; use tf.keras.models.save_model with save_format='tf' instead.
Deprecated; use tf.keras.models.load_model instead.
Use DenseFeatures in place of the deprecated tf.feature_column.input_layer.
Deprecated.
Use save_format='tf' to save in SavedModel format as the replacement for the deprecated experimental export API.
The traditional graph-building and Session execution model is discouraged in favor of regular Python functions.
New APIs and options 53
The NOT_EQUAL operator adds int16x8 support in tf.lite.
The SQRT operator adds int8 support in tf.lite.
The SQRT operator adds int16x8 support in tf.lite.
tf.data adds NoneTensorSpec to the public API so None values in element_spec can be identified with isinstance.
tfl.cast adds support for int2 and int4.
tf.lite adds support for the uint4 type.
Provide this argument to converter.convert() to trigger TensorRT calibration.
Added a CompositeTensor base class and support for CompositeTensors in TensorSpec and tf.function arguments.
Adds the adjoint operation to LinearOperator.
Adds H as an alias for the LinearOperator adjoint.
Added LinearOperatorHouseholder.
Added LinearOperatorToeplitz.
Added key and skip methods.
Adds an API for collecting graph and profile information.
TensorFlow now produces a tensorflow_core package containing the code and a tensorflow virtual package that forwards to it.
Set the build define to 0 to disable MKL-DNN contraction kernels.
Setting this environment variable to TRUE or 1 forces deterministic cuDNN convolution and max-pooling algorithms and deterministic algorithm selection.
Added compatibility support for restoring the previous Tensor equality behavior.
CriticalSection is exposed in core as tf.CriticalSection.
Added TensorArray support, RaggedTensor integration, cross-device user functions, and support for nested datasets in tensor creation, batching, and unbatching.
Set experimental_slack to True to introduce pipeline slack and reduce CPU contention.
Adds num_parallel_reads and support for passing a Dataset of filenames.
Disable v2 control flow with this toggle.
Added ellipsis (...) support.
Enable v2 control flow with this toggle.
Decorate regular Python functions to turn them into graphs that can be executed remotely, serialized, and optimized; CompositeTensor arguments receive basic support.
Added batch_dims support and corrected behavior when axis=None and batch_dims is negative.
Keras is the central high-level API for building and training models in TensorFlow 2.0, with eager execution and tf.data input pipelines.
Added as a public Keras backend API.
add_update can take a zero-argument callable, allowing updates to be disabled when a layer is non-trainable in eager training.
Preferred implementation for custom RNN cells in TensorFlow 2.0.
Added a dynamic constructor argument, which should be True when using imperative control flow in call.
Added implementation=3, which stores weights in a SparseTensor for faster large sparse models.
Added AUTO, NONE, SUM, and SUM_OVER_BATCH_SIZE loss reduction types; distribution-strategy contexts impose restrictions on their use.
Added v2 sparse categorical crossentropy metric and AUCCurve and AUCSummationMethod enums.
Added the tridiagonal multiplication operation.
Added the tridiagonal solve operation, a partial_pivoting input parameter, and a gradient.
Added a cumulative log-sum-exp operation.
Added the nextafter operation.
Utility to help scale losses in custom training loops.
Utility to help scale regularization losses in custom training loops.
Added boolean masking for ragged tensors.
Added stacking support for ragged tensors.
Added placeholder support for RaggedTensor.
Added a binomial random-number operation.
Added a utility to convert dense tensors to sparse tensors.
Added byte_split for string tensors.
Added a result_type parameter and support for inputs of any rank.
Added an unsorted segment join operation for strings.
Added branch selection based on a branch_index.
Wrap an optimizer class to enable automatic mixed-precision graph rewriting for float16 acceleration on Volta and Turing Tensor Cores.
Set TF2_BEHAVIOR=1 to enable v2 behavior, including v2 control flow.
Added Python API support, including from_saved_model, from_keras_file, and from_concrete_functions.
Behavior and default changes 14
The EQUAL operator adds int16x8 support in tf.lite.
tf.image.decode_image adds JPEG XL support.
tfl.fully_connected adds support for SRQ int2.
add_metric is now supported in graph function mode.
Turned on by default; disable when building with --define=tensorflow_mkldnn_contraction_kernel=0.
Emits StatelessIf when branch functions are stateless and do not touch resources; v2 control flow also accepts a one-element nonscalar predicate.
Promoted enumerate_dataset from the experimental API to the core Dataset API.
The cycle_length argument can now default to the number of schedulable CPU cores.
Promoted unbatch from the experimental API to the core Dataset API.
Now works in eager mode and supports callbacks.
Added broadcasting support.
Emits StatelessWhile when condition and body functions are stateless and do not touch resources.
The precision_mode argument is now case insensitive.
These losses now support both binary and -1/1 label input.
Tooling 1
Added support for the tflite_convert command-line tool in TensorFlow 2.0.
Fixes and other changes 3
tf.lite adds support for the int2 type.
tfl.slice adds support for int4.
Fixes callbacks not logging values in eager mode when used with a deferred build model.
tensorflow 166 changes
Breaking changes 36
Division follows Python flooring semantics, including tf.div; use tf.truncatediv for forced integer truncation.
Division and modulus operators follow Python flooring semantics.
Modulus follows Python flooring semantics, including tf.mod; use tf.truncatemod for forced integer truncation.
The Empty op is now stateful.
Several Python API calls change to resemble NumPy more closely; the release notes list specific API changes below.
Removed from the public API; use C++ shape function registration instead.
The argument order changes to labels, predictions, and named arguments are required.
The argument order changes to labels, predictions, and named arguments are required.
The argument order changes to labels, predictions, and named arguments are required.
Renamed to SparseTensor.dense_shape.
Renamed to SparseTensorValue.dense_shape.
The existing SyncReplicasOptimizer is removed; SyncReplicasOptimizerV2 is renamed to SyncReplicasOptimizer.
The var_scope property is renamed to variable_scope.
In the C++ API, Input, Output, and related types move from the tensorflow::ops namespace to tensorflow.
Moves to contrib/tensor_forest.
Replace with tf.summary.audio; summary ops now take name rather than tag as their first argument and respect name scopes.
Removed from the Python interface; use tf.abs, which supports complex tensors.
Arguments are reordered to match NumPy as values, axis, name.
TensorForestEstimator moves to contrib/tensor_forest.
Replace with tf.summary.histogram; summary ops now take name rather than tag as their first argument and respect name scopes.
Replace with tf.summary.image; summary ops now take name rather than tag as their first argument and respect name scopes.
Defaults to a faster DCT method with slightly reduced fidelity; set dct_method to INTEGER_ACCURATE to restore the old behavior.
Renamed to tf.reciprocal for component-wise reciprocal, avoiding confusion with matrix inversion.
Renamed to tf.setdiff1d to match NumPy naming.
Metrics weight broadcasting is stricter.
Most functions move temporarily to tf.contrib.rnn, except dynamic_rnn and raw_rnn.
RNN cell APIs move temporarily to tf.contrib.rnn; they are planned to move back into core for TF 1.1.
Now returns a callable that must be called with initializer arguments.
The second argument now takes indices of axes to reverse instead of a boolean mask.
Uses banker's rounding, or round-to-even semantics, to match NumPy.
Replace with tf.summary.scalar, whose first argument is name rather than tag and which respects TensorFlow name scopes.
Arguments are reordered to match NumPy as sp_input, num_split, axis; the function temporarily requires keyword arguments.
Arguments are reordered to match NumPy: value, num_or_size_splits, axis.
Replace with tf.summary.FileWriter.
Replace with tf.summary.FileWriterCache.
Now returns a callable that must be called with initializer arguments; update code to use tf.zeros_initializer().
Deprecations 9
Dimension arguments across the listed Python functions use axis in place of older keywords such as dimension, dim, and reduction_indices; old keywords remain temporarily for compatibility.
_ref dtypes are deprecated in the Python API.
Deprecated in favor of TensorArray.stack.
Deprecated in favor of TensorArray.unstack.
Deprecated in favor of tf.multiply.
Deprecated in favor of tf.negative.
Deprecated in favor of tf.stack.
Deprecated in favor of tf.subtract.
Deprecated in favor of tf.unstack.
New APIs and options 15
Adds a lookup table mapping indices to strings.
Accepts an optional custom_getter_ parameter.
A new op, parallel_stack, is added.
TensorFlow can now be installed with the standard pip install command.
Adds a feature column that transforms string features to IDs using a vocabulary file.
A new op is added for the StagingArea queue-like facility.
A new queue-like StagingArea and the stage and unstage ops are added.
Adds a lookup table mapping strings to indices.
Adds a convenience function to filter variable lists using regular expressions.
Adds image rotation for arbitrary angles.
Common compression option constants are introduced for RecordReader and RecordWriter.
saved_model is available through tf.saved_model.
Use tf.truncatediv to obtain forced integer truncation behavior.
Use tf.truncatemod to obtain forced integer truncation behavior.
TensorFlow Debugger adds a command-line interface and API.
Performance 2
CPU scatter_update is faster for ASSIGN operations.
String concatenation is faster.
Behavior and default changes 3
In-place update ops for strings are enabled on CPU.
tf.div remains available, but its semantics do not respond to Python 3 or from future mechanisms.
tf.divide is the recommended division function and now honors its name field.
Fixes and other changes 1
Supports restoring a session from v2 checkpoint files.