ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

tf.compat.v1.Dimension

Represents the value of one dimension in a TensorShape.

value The value of this dimension, or None if it is unknown.

Methods

assert_is_compatible_with

View source

Raises an exception if other is not compatible with this Dimension.

Args
other Another Dimension.

Raises
ValueError If self and other are not compatible (see is_compatible_with).

is_compatible_with

View source

Returns true if other is compatible with this Dimension.

Two known Dimensions are compatible if they have the same value. An unknown Dimension is compatible with all other Dimensions.

Args
other Another Dimension.

Returns
True if this Dimension and other are compatible.

merge_with

View source

Returns a Dimension that combines the information in self and other.

Dimensions are combined as follows:

tf.compat.v1.Dimension(n)   .merge_with(tf.compat.v1.Dimension(n))     ==
tf.compat.v1.Dimension(n)
tf.compat.v1.Dimension(n)   .merge_with(tf.compat.v1.Dimension(None))  ==
tf.compat.v1.Dimension(n)
tf.compat.v1.Dimension(None).merge_with(tf.compat.v1.Dimension(n))     ==
tf.compat.v1.Dimension(n)
# equivalent to tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None).merge_with(tf.compat.v1.Dimension(None))

# raises ValueError for n != m
tf.compat.v1.Dimension(n)   .merge_with(tf.compat.v1.Dimension(m))

Args
other Another Dimension.

Returns
A Dimension containing the combined information of self and other.

Raises
ValueError If self and other are not compatible (see is_compatible_with).

__add__

View source

Returns the sum of self and other.

Dimensions are summed as follows:

tf.compat.v1.Dimension(m)