tf.compat.dimension_value | TensorFlow v2.16.1 (original) (raw)
tf.compat.dimension_value
Stay organized with collections Save and categorize content based on your preferences.
Compatibility utility required to allow for both V1 and V2 behavior in TF.
View aliases
Compat aliases for migration
SeeMigration guide for more details.
tf.compat.v1.compat.dimension_value, tf.compat.v1.dimension_value
tf.compat.dimension_value(
dimension: Union['Dimension', int, None]
) -> Union[int, None]
Used in the notebooks
Used in the tutorials |
---|
Learnable Distributions Zoo |
Until the release of TF 2.0, we need the legacy behavior of TensorShape
to coexist with the new behavior. This utility is a bridge between the two.
When accessing the value of a TensorShape dimension, use this utility, like this:
# If you had this in your V1 code:
value = tensor_shape[i].value
# Use `dimension_value` as direct replacement compatible with both V1 & V2:
value = dimension_value(tensor_shape[i])
# This would be the V2 equivalent:
value = tensor_shape[i] # Warning: this will return the dim value in V2!
Args | |
---|---|
dimension | Either a Dimension instance, an integer, or None. |
Returns |
---|
A plain value, i.e. an integer or None. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.