tf.compat.v1.Dimension | TensorFlow v2.16.1 (original ) (raw )Represents the value of one dimension in a TensorShape.
tf.compat.v1.Dimension(
value
)
Migrate to TF2In TF2, members of a TensorShape object are integers. The Dimension class is not part of TF2's data model.
Please refer to the TensorShape section of the migration guide on common code patterns adapting Dimension objects to a TF2 syntax.
Description
Attributes
value
The value of this dimension, or None if it is unknown.
Methodsassert_is_compatible_withView source
assert_is_compatible_with(
other
)
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_withView source
is_compatible_with(
other
)
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_withView source
merge_with(
other
)
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 andother.
Raises
ValueError
If self and other are not compatible (see is_compatible_with).
__add__View source
__add__(
other
)
Returns the sum of self and other.
Dimensions are summed as follows:
tf.compat.v1.Dimension(m) + tf.compat.v1.Dimension(n) ==
tf.compat.v1.Dimension(m + n)
tf.compat.v1.Dimension(m) + tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) + tf.compat.v1.Dimension(n) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) + tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the sum of self and other.
__bool__View source
__bool__()
Equivalent to bool(self.value).
__div__View source
__div__(
other
)
This function exists only for backwards compatibility purposes; new code should use __floordiv__ via the syntax x // y. Using x // ycommunicates clearly that the result rounds down, and is forward compatible to Python 3.
Args
other
Another Dimension.
Returns
A Dimension whose value is the integer quotient of self and other.
__eq__View source
__eq__(
other
)
Returns true if other has the same known value as this Dimension.
__floordiv__View source
__floordiv__(
other
)
Returns the quotient of self and other rounded down.
Dimensions are divided as follows:
tf.compat.v1.Dimension(m) // tf.compat.v1.Dimension(n) ==
tf.compat.v1.Dimension(m // n)
tf.compat.v1.Dimension(m) // tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) // tf.compat.v1.Dimension(n) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) // tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the integer quotient of self and other.
__ge__View source
__ge__(
other
)
Returns True if self is known to be greater than or equal to other.
Dimensions are compared as follows:
(tf.compat.v1.Dimension(m) >= tf.compat.v1.Dimension(n)) == (m >= n)
(tf.compat.v1.Dimension(m) >= tf.compat.v1.Dimension(None)) == None
(tf.compat.v1.Dimension(None) >= tf.compat.v1.Dimension(n)) == None
(tf.compat.v1.Dimension(None) >= tf.compat.v1.Dimension(None)) == None
Args
other
Another Dimension.
Returns
The value of self.value >= other.value if both are known, otherwise None.
__gt__View source
__gt__(
other
)
Returns True if self is known to be greater than other.
Dimensions are compared as follows:
(tf.compat.v1.Dimension(m) > tf.compat.v1.Dimension(n)) == (m > n)
(tf.compat.v1.Dimension(m) > tf.compat.v1.Dimension(None)) == None
(tf.compat.v1.Dimension(None) > tf.compat.v1.Dimension(n)) == None
(tf.compat.v1.Dimension(None) > tf.compat.v1.Dimension(None)) == None
Args
other
Another Dimension.
Returns
The value of self.value > other.value if both are known, otherwise None.
__le__View source
__le__(
other
)
Returns True if self is known to be less than or equal to other.
Dimensions are compared as follows:
(tf.compat.v1.Dimension(m) <= tf.compat.v1.Dimension(n)) == (m <= n)
(tf.compat.v1.Dimension(m) <= tf.compat.v1.Dimension(None)) == None
(tf.compat.v1.Dimension(None) <= tf.compat.v1.Dimension(n)) == None
(tf.compat.v1.Dimension(None) <= tf.compat.v1.Dimension(None)) == None
Args
other
Another Dimension.
Returns
The value of self.value <= other.value if both are known, otherwise None.
__lt__View source
__lt__(
other
)
Returns True if self is known to be less than other.
Dimensions are compared as follows:
(tf.compat.v1.Dimension(m) < tf.compat.v1.Dimension(n)) == (m < n)
(tf.compat.v1.Dimension(m) < tf.compat.v1.Dimension(None)) == None
(tf.compat.v1.Dimension(None) < tf.compat.v1.Dimension(n)) == None
(tf.compat.v1.Dimension(None) < tf.compat.v1.Dimension(None)) == None
Args
other
Another Dimension.
Returns
The value of self.value < other.value if both are known, otherwise None.
__mod__View source
__mod__(
other
)
Returns self modulo other.
Dimension modulo are computed as follows:
tf.compat.v1.Dimension(m) % tf.compat.v1.Dimension(n) ==
tf.compat.v1.Dimension(m % n)
tf.compat.v1.Dimension(m) % tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) % tf.compat.v1.Dimension(n) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) % tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is self modulo other.
__mul__View source
__mul__(
other
)
Returns the product of self and other.
Dimensions are summed as follows:
tf.compat.v1.Dimension(m) * tf.compat.v1.Dimension(n) ==
tf.compat.v1.Dimension(m * n)
tf.compat.v1.Dimension(m) * tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) * tf.compat.v1.Dimension(n) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) * tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the product of self and other.
__ne__View source
__ne__(
other
)
Returns true if other has a different known value from self.
__radd__View source
__radd__(
other
)
Returns the sum of other and self.
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the sum of self and other.
__rdiv__View source
__rdiv__(
other
)
Use __floordiv__ via x // y instead.
This function exists only to have a better error message. Instead of:TypeError: unsupported operand type(s) for /: 'int' and 'Dimension', this function will explicitly call for usage of // instead.
Args
other
Another Dimension.
__rfloordiv__View source
__rfloordiv__(
other
)
Returns the quotient of other and self rounded down.
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the integer quotient of self and other.
__rmod__View source
__rmod__(
other
)
Returns other modulo self.
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is other modulo self.
__rmul__View source
__rmul__(
other
)
Returns the product of self and other.
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the product of self and other.
__rsub__View source
__rsub__(
other
)
Returns the subtraction of self from other.
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the subtraction of self from other.
__rtruediv__View source
__rtruediv__(
other
)
Use __floordiv__ via x // y instead.
This function exists only to have a better error message. Instead of:TypeError: unsupported operand type(s) for /: 'int' and 'Dimension', this function will explicitly call for usage of // instead.
Args
other
Another Dimension.
__sub__View source
__sub__(
other
)
Returns the subtraction of other from self.
Dimensions are subtracted as follows:
tf.compat.v1.Dimension(m) - tf.compat.v1.Dimension(n) ==
tf.compat.v1.Dimension(m - n)
tf.compat.v1.Dimension(m) - tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) - tf.compat.v1.Dimension(n) # equiv. to
tf.compat.v1.Dimension(None)
tf.compat.v1.Dimension(None) - tf.compat.v1.Dimension(None) # equiv. to
tf.compat.v1.Dimension(None)
Args
other
Another Dimension, or a value accepted by as_dimension.
Returns
A Dimension whose value is the subtraction of other from self.
__truediv__View source
__truediv__(
other
)
Use __floordiv__ via x // y instead.
This function exists only to have a better error message. Instead of:TypeError: unsupported operand type(s) for /: 'Dimension' and 'int', this function will explicitly call for usage of // instead.
Args
other
Another Dimension.