tf.Dimension

tf.Dimension

class tf.Dimension

Defined in tensorflow/python/framework/tensor_shape.py.

See the guide: Building Graphs > Defining new operations

Represents the value of one dimension in a TensorShape.

Properties

value

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

Methods

__init__

__init__(value)

Creates a new Dimension with the given value.

__add__

__add__(other)

Returns the sum of self and other.

Dimensions are summed as follows:

Dimension(m) + Dimension(n) == Dimension(m + n) Dimension(m) + Dimension(None) == Dimension(None) Dimension(None) + Dimension(n) == Dimension(None) Dimension(None) + Dimension(None) == Dimension(None)

Args:

  • other: Another Dimension.

Returns:

A Dimension whose value is the sum of self and other.

__div__

__div__(other)

DEPRECATED: Use __floordiv__ via x // y instead.

This function exists only for backwards compatibility purposes; new code should use __floordiv__ via the syntax x // y. Using x // y communicates 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__

__eq__(other)

Returns true if other has the same known value as this Dimension.

__floordiv__

__floordiv__(other)

Returns the quotient of self and other rounded down.

Dimensions are divided as follows:

Dimension(m) // Dimension(n) == Dimension(m // n) Dimension(m) // Dimension(None) == Dimension(None) Dimension(None) // Dimension(n) == Dimension(None) Dimension(None) // Dimension(None) == Dimension(None)

Args:

  • other: Another Dimension.

Returns:

A Dimension whose value is the integer quotient of self and other.

__ge__

__ge__(other)

Returns True if self is known to be greater than or equal to other.

Dimensions are compared as follows:

Dimension(m) >= Dimension(n) == m >= n Dimension(m) >= Dimension(None) == None Dimension(None) >= Dimension(n) == None Dimension(None) >= Dimension(None) == None

Args:

  • other: Another Dimension.

Returns:

The value of self.value >= other.value if both are known, otherwise None.

__gt__

__gt__(other)

Returns True if self is known to be greater than other.

Dimensions are compared as follows:

Dimension(m) > Dimension(n) == m > n Dimension(m) > Dimension(None) == None Dimension(None) > Dimension(n) == None Dimension(None) > Dimension(None) == None

Args:

  • other: Another Dimension.

Returns:

The value of self.value > other.value if both are known, otherwise None.

__index__

__index__()

__int__

__int__()

__le__

__le__(other)

Returns True if self is known to be less than or equal to other.

Dimensions are compared as follows:

Dimension(m) <= Dimension(n) == m <= n Dimension(m) <= Dimension(None) == None Dimension(None) <= Dimension(n) == None Dimension(None) <= Dimension(None) == None

Args:

  • other: Another Dimension.

Returns:

The value of self.value <= other.value if both are known, otherwise None.

__lt__

__lt__(other)

Returns True if self is known to be less than other.

Dimensions are compared as follows:

Dimension(m) < Dimension(n) == m < n Dimension(m) < Dimension(None) == None Dimension(None) < Dimension(n) == None Dimension(None) < Dimension(None) == None

Args:

  • other: Another Dimension.

Returns:

The value of self.value < other.value if both are known, otherwise None.

__mod__

__mod__(other)

Returns self modulo `other.

Dimension moduli are computed as follows:

Dimension(m) % Dimension(n) == Dimension(m % n) Dimension(m) % Dimension(None) == Dimension(None) Dimension(None) % Dimension(n) == Dimension(None) Dimension(None) % Dimension(None) == Dimension(None)

Args:

  • other: Another Dimension.

Returns:

A Dimension whose value is self modulo other.

__mul__

__mul__(other)

Returns the product of self and other.

Dimensions are summed as follows:

Dimension(m)    * Dimension(n)    == Dimension(m * n)
Dimension(m)    * Dimension(None) == Dimension(None)
Dimension(None) * Dimension(n)    == Dimension(None)
Dimension(None) * Dimension(None) == Dimension(None)

Args:

  • other: Another Dimension.

Returns:

A Dimension whose value is the product of self and other.

__ne__

__ne__(other)

Returns true if other has a different known value from self.

__sub__

__sub__(other)

Returns the subtraction of other from self.

Dimensions are subtracted as follows:

Dimension(m) - Dimension(n) == Dimension(m - n) Dimension(m) - Dimension(None) == Dimension(None) Dimension(None) - Dimension(n) == Dimension(None) Dimension(None) - Dimension(None) == Dimension(None)

Args:

  • other: Another Dimension.

Returns:

A Dimension whose value is the subtraction of sum of other from self.

assert_is_compatible_with

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_with

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_with

merge_with(other)

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

Dimensions are combined as follows:

Dimension(n)   .merge_with(Dimension(n))    == Dimension(n)
Dimension(n)   .merge_with(Dimension(None)) == Dimension(n)
Dimension(None).merge_with(Dimension(n))    == Dimension(n)
Dimension(None).merge_with(Dimension(None)) == Dimension(None)
Dimension(n)   .merge_with(Dimension(m)) raises ValueError for n != 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).

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/Dimension

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部